tf-idf应该帮助,因为它结合了
- 的次数一个词出现在文档中(即每本书)
- 单词出现在一组文档中的次数(a 。K a。语料库)
如果一个词出现在文档中了很多,但没有这么多的主体,是对文件的可能特性,将具有较高的TF-IDF得分。另一方面,如果一个词经常出现在一个文档中,而且经常出现在整个语料库中,那么这个文档就不是很有特点,并且这个文档没有很高的tf-idf分数。每个文档中具有最高tf-idf度量的词是最相关的。
停止词删除可能是你想要想获得TF-IDF措施,您的文件之前,对数据进行了一步,但你可能要与不停止的话,试图比较性能。
编辑:
为了支持我在评论中提到的内容。不必拿出自己停止词,这里的NLTK的英文停用词,您可以添加或删除根据任何你想要实现:
>>> import nltk
>>> from nltk.corpus import stopwords
>>> stopwords.words('english')
['i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you',
'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his',
'himself', 'she', 'her', 'hers', 'herself', 'it', 'its', 'itself',
'they', 'them', 'their', 'theirs', 'themselves', 'what', 'which',
'who', 'whom', 'this', 'that', 'these', 'those', 'am', 'is', 'are',
'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'having',
'do', 'does', 'did', 'doing', 'a', 'an', 'the', 'and', 'but', 'if',
'or', 'because', 'as', 'until', 'while', 'of', 'at', 'by', 'for',
'with', 'about', 'against', 'between', 'into', 'through', 'during',
'before', 'after', 'above', 'below', 'to', 'from', 'up', 'down',
'in', 'out', 'on', 'off', 'over', 'under', 'again', 'further', 'then',
'once', 'here', 'there', 'when', 'where', 'why', 'how', 'all', 'any',
'both', 'each', 'few', 'more', 'most', 'other', 'some', 'such', 'no',
'nor', 'not', 'only', 'own', 'same', 'so', 'than', 'too', 'very', 's',
't', 'can', 'will', 'just', 'don', 'should', 'now']
我认为类似你的方式。谢谢。 实际上,维护一个停止词列表是不可能的,我的问题。因为在文档中,看起来像停用词的单词可能会以比平常高的分布发生。我也不想错过这些不寻常的单词,但要消除平常/正常分布的单词。 无论如何,我会试试看。 – Muatik
stopword lists存在于许多软件包中预制,你不必自己想出或维护任何东西:)只是为了澄清,这不是我的方式 - tf-idf是一个在信息检索等已知的统计措施。另一个除了答案中的链接:http://nlp.stanford.edu/IR-book/html/htmledition/tf-idf-weighting-1.html – arturomp