多版本中文停用詞詞表 + 多版本英文停用詞詞表 + python詞表合併程序

原文地址:我的CSDN博客

文章簡介與更新記錄

如果你只想獲取中文停用詞此表,請直接到文章結尾下載項目文件,其中包括三個中文停用詞詞表,一個英文停用詞詞表和一個合併詞表的.py文件

  • 2017/07/04 創建文章,上傳文件
  • 2017/07/04 更新了合併代碼,添加了新的中文停用詞表(哈工大擴展版本)和一個新的停用詞表,現在最全的中文停用詞表為1927,添加了英文和中英文停用詞表英文停用詞詞表為1199

停用詞

在進行漢語自然語言處理時候,分詞是必不可少的環節,但是在實際的自然語言中,有很多的非實意詞語或者其他並沒有實際作用的詞語,這些詞語我們必須在分詞環節後進行過濾—這個環節也就是過濾停用詞.不過想要獲得好的分詞效果,必須首先進行比較好的分詞處理.這一點也是十分重要的.

python合併中文停用詞詞表的代碼

# - * - coding: utf - 8 -*-## 作者:田豐(FontTian)# 創建時間:2017/7/4# 郵箱:fonttian@Gmaill.com# CSDN:http://blog.csdn.net/fontthroneimport sysreload(sys)sys.setdefaultencoding(utf-8)# 獲取停用詞的Listdef GetListOfStopWords(filepath): f_stop = open(filepath) try: f_stop_text = f_stop.read() f_stop_text = unicode(f_stop_text, utf-8) finally: f_stop.close() f_stop_seg_list = f_stop_text.split(
) return f_stop_seg_list# 保存Listdef SaveFile(list, filename): f_stop = open(filename, w) for item in range(len(list)): if item != len(list): f_stop.writelines((list[item].encode(utf-8)) +
) else: f_stop.writelines(list[item].encode(utf-8)) f_stop.close()# 求List並集def GetListUnion(listName): ListUnion = [!] for item in listName: # print item ListUnion.extend(GetListOfStopWords(item)) return list(set(ListUnion))def GetStopWords(listOfFileName, FileName=CNstopwords.txt, keynumber=1): stopwords_pathCN = CNstopwords.txt # 默認中文總表 1 stopwords_pathEN = ENstopwords.txt # 默認英文總表 2 stopwords_pathCNEN = CNENstopwords.txt # 默認中英文混合總表 4 if keynumber == 1: listOfFileName.append(stopwords_pathCN) elif keynumber == 2: listOfFileName.append(stopwords_pathEN) elif keynumber == 3: listOfFileName.append(stopwords_pathCN) listOfFileName.append(stopwords_pathEN) elif keynumber == 5: listOfFileName.append(stopwords_pathCN) listOfFileName.append(stopwords_pathCNEN) elif keynumber == 6: listOfFileName.append(stopwords_pathEN) listOfFileName.append(stopwords_pathCNEN) elif keynumber == 7: listOfFileName.append(stopwords_pathCN) listOfFileName.append(stopwords_pathEN) listOfFileName.append(stopwords_pathCNEN) else: listOfFileName.append(stopwords_pathCN) print The keynumber is wrong,chage keynumber to 1 listOfFileName.append(stopwords_pathCNEN) ListUnion = GetListUnion(listOfFileName) SaveFile(ListUnion, FileName)stopwords_pathCN = CNstopwords.txt # 默認中文總表 1stopwords_pathEN = CNstopwords.txt # 默認英文總表 2stopwords_pathCNEN = CNstopwords.txt # 默認中英文混合總表 4listOfFileName = []# 需要添加的 中文 停用詞詞表stopwords_path1 = stopwords1893.txtstopwords_path2 = stopwords1229.txtstopwords_path3 = stopwordshagongdakuozhan.txtstopwords_path4 = stop_words_zh.txt# 需要添加的 英文 停用詞詞表stopwords_path5 = stop_words_eng.txtstopwords_path6 = ENstopwords891.txt# 需要添加的 中文 停用詞詞表路徑# listOfFileName.append(stopwords_path1)# listOfFileName.append(stopwords_path2)# listOfFileName.append(stopwords_path3)# listOfFileName.append(stopwords_path4)# 需要添加的 英文 停用詞詞表路徑listOfFileName.append(stopwords_path5)listOfFileName.append(stopwords_path6)GetStopWords(listOfFileName, FileName=ENstopwords.txt, keynumber=2)

百度雲下載所有文件

下載地址:pan.baidu.com/s/1dFjDj3

推薦閱讀:

用Python實現線性回歸,8種方法哪個最高效?
iForest (Isolation Forest)孤立森林 異常檢測 入門篇
Pandas(十一) 時間序列處理
NLP系列學習:CRF條件隨機場(1)
RF、GBDT、XGBoost常見面試題整理

TAG:自然語言處理 | 機器學習 |