數(shù)據(jù)分析 小白筆記
1辟狈、文本分詞
import jieba
s = "中國新聞網(wǎng)8677條新聞"
cut = jieba.lcut(s)
print(cut)
2爵政、去停用詞
下載停用詞庫
import jieba
stop_words = []
s = "中國0新聞網(wǎng)不問8677條新聞"
def load_stop_words(path = 'stop_words.txt'):
with open(path,'r') as f:
for line in f:
content = line.strip()
stop_words.append(content)
load_stop_words()
lcut = jieba.lcut(s)
cut = [x for x in lcut if x not in stop_words]
print(cut)