Python 去除停用词
停用词是英语句子中没有太多意义的词语。它们可以被安全地忽略,而不损失句子的意义。例如,像the、he、have等词语。这些词语已经在名为corpus的语料库中被捕捉到。我们首先将其下载到我们的Python环境中。
它将下载一个包含英文停用词的文件。
验证停用词
当我们运行上面的程序时,我们得到以下输出-
[u'your', u'yours', u'yourself', u'yourselves', u'he', u'him', u'his', u'himself', u'she',
u"she's", u'her', u'hers', u'herself', u'it', u"it's", u'its', u'itself', u'they', u'them',
u'their', u'theirs', u'themselves', u'what', u'which', u'who', u'whom', u'this',
u'that', u"that'll", u'these', u'those', u'am', u'is', u'are', u'was', u'were', u'be',
u'been', u'being', u'have', u'has', u'had', u'having', u'do', u'does', u'did', u'doing',
u'a', u'an', u'the', u'and', u'but', u'if', u'or', u'because', u'as', u'until',
u'while', u'of', u'at']
除了英语之外,具有这些停用词的其他语言如下:
当我们运行上面的程序时,我们得到以下输出 –
示例
我们使用下面的示例来展示如何从单词列表中删除停止词。
当我们运行上面的程序时,我们得到以下输出 –