【问题标题】:Is there any python library for searching specific words like "the", "is", "was", "am" .... and other similar words? [closed]是否有任何用于搜索特定单词的 python 库,如 "the"、"is"、"was"、"am" .... 和其他类似单词? [关闭]
【发布时间】:2022-01-05 17:13:31
【问题描述】:

我想从文本文件中排除这些词。目前,我的代码只计算文本文件中所有单词的出现次数,但我想排除前面提到的这些不需要的单词,只计算某些重要单词的出现频率。文件中有很多重要的词,所以我不能全部包含在内。所以如果python中有一个预先存在的库会很有帮助

【问题讨论】:

  • nltk 有预定义的停用词列表。
  • 为什么不通过排除特定的词来清理文本,然后做一个计数器返回词频?
  • 您好,感谢您的帮助。我会调查的

标签: python nlp open-source pypi


【解决方案1】:

此类词称为停用词,您可以使用nltk 库轻松删除它们

from nltk.corpus import stopwords
# print(list(stopwords.words('english')))
filtered_words = [word for word in word_list if word not in stopwords.words('english')]

【讨论】:

    猜你喜欢
    • 2018-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-16
    • 1970-01-01
    • 1970-01-01
    • 2019-06-13
    相关资源
    最近更新 更多