Use jieba third-party library to extract keywords from files

The Doubaqiong text that has been crawled is stored in the form of TXT

code

import jieba.analyse
path = 'C:/Users/Administrator/Desktop/bishe/doupo.text'
fp = open(path,'r')
content = fp.read()
try:
    jieba.analyse.set_stop_words('C:/Users/Administrator/Desktop/bishe/aa.txt')
    tags = jieba.analyse.extract_tags(content, topK=15, withWeight=True)
    for item in tags:
        print(item[0]+'\t'+str(int(item[1]*1000)))
finally:
    fp.close()

result

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325158986&siteId=291194637