資源簡介
內含7kb的停用詞詞典、源碼、測試數據;詞典共收錄了1208個常見停用詞,源碼基于python3,下載解壓后即可運行測試數據,且效率非常高。歡迎下載使用,如在使用過程中有任何問題,歡迎留言交流。

代碼片段和文件信息
from?time?import?sleep
f1?=?open(‘./data.txt‘‘r‘)??#需要去除停用詞的數據
f2?=?open(‘./stop_words.txt‘‘r‘)??#導入停用詞詞典
f3?=?open(‘./result.txt‘‘w‘encoding=‘utf-8‘)??#存儲結果
s?=?f2.read().split(‘\n‘)
for?line?in?f1:
line?=?line.strip(‘\n‘).strip(‘?‘)
line?=?line.split(‘?‘)
sw?=?‘‘
for?ch?in?line:
flag?=?0
for?sh?in?s:
if?sh==ch:
flag?=?1
break
if?flag==0:
sw?=?sw?+?ch?+?‘?‘
f3.write(sw?+?‘\n‘)
f1.close()
f2.close()
f3.close()
print(‘\n[--finished--]‘)
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????533??2019-01-29?16:23??DropStopWords\DropStopWords.py
?????文件??????????73??2019-01-29?16:23??DropStopWords\data.txt
?????文件??????????28??2019-01-29?16:23??DropStopWords\result.txt
?????文件????????7041??2018-11-23?23:04??DropStopWords\stop_words.txt
?????目錄???????????0??2019-01-29?16:23??DropStopWords\
- 上一篇:高效爬取微博數據python3實現
- 下一篇:PCV---python工具包.zip
評論
共有 條評論