文本分析-中文停用词集合(结合百度停用词表、哈工大停用词表、四川大学机器智能实验室停用词库、中文停用词表等)

将这4个停用词表进行组合并去重。

# _*_coding:utf-8 _*_

import os
#得到当前文件路径
current_path=os.getcwd()
#获取文件列表
list_file=os.listdir(current_path)
#用来存储停用词
temp_stopwords=[]
for file in list_file:
    file_tail=file.split('.')[-1]
    #只要txt格式的文件
    if file_tail=='txt':
        file_path=os.path.join(current_path,file)
        with open(file_path,'r',encoding='utf-8') as doc:
            content=doc.readlines()
            for words in content:
                if words not in temp_stopwords:
                    temp_stopwords.append(words)
# print(len(temp_stopwords))
#去重之后又2317个停用词
output:
 2317
#将去重之后的停用词存储下来
with open('./merge_stopword.txt','w',encoding='utf-8')  as f:
    for word in temp_stopwords:
        f.write(word)

可以在上面直接下载去重之后的停用词

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值