日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python停用词表_多版本中文停用词词表 + 多版本英文停用词词表 + python词表合并程序...

發布時間:2025/3/8 python 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python停用词表_多版本中文停用词词表 + 多版本英文停用词词表 + python词表合并程序... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章簡介與更新記錄

如果你只想獲取中文停用詞此表,請直接到文章結尾下載項目文件,其中包括三個中文停用詞詞表,一個英文停用詞詞表和一個合并詞表的.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/fontthrone

import sys

reload(sys)

sys.setdefaultencoding('utf-8')

# 獲取停用詞的List

def 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('\n')

return f_stop_seg_list

# 保存List

def 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')) + '\n')

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' # 默認中文總表 1

stopwords_pathEN = 'CNstopwords.txt' # 默認英文總表 2

stopwords_pathCNEN = 'CNstopwords.txt' # 默認中英文混合總表 4

'''

listOfFileName = []

# 需要添加的 中文 停用詞詞表

stopwords_path1 = 'stopwords1893.txt'

stopwords_path2 = 'stopwords1229.txt'

stopwords_path3 = 'stopwordshagongdakuozhan.txt'

stopwords_path4 = 'stop_words_zh.txt'

# 需要添加的 英文 停用詞詞表

stopwords_path5 = 'stop_words_eng.txt'

stopwords_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)

百度云下載所有文件

總結

以上是生活随笔為你收集整理的python停用词表_多版本中文停用词词表 + 多版本英文停用词词表 + python词表合并程序...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。