# @Time : 2021/3/16 19:54
# @Author : chao
#名词提取
from collections import Counter
f1 = open(r'C:\Users\代码\去除停用词并分词\去除停用词并分词结果\zong_fengci_tingyongci2.txt',
'r', encoding='utf-8')
#构建一个空列表,用以保存提取出的每个词
words = []
#构建一个空列表,用于保存提取出的名词
ming_words = []
for i in f1.readlines():
#print(i.replace('x','').split(" "))
line = i.split(" ")
for j in line:
if(j!='' and j!='\n' and j!='x'):
words.append(j)
#提取名词
for i in words:
#if('n' in i):
ming_words.append(i)
#统计词频
counter = Counter(ming_words)
dictionary=dict(counter)
# get to k most frequently occuring words
k=100
res=counter.most_common(k)
print(res)
(六)文本挖掘——名词提取
最新推荐文章于 2024-07-19 06:51:46 发布