【发布时间】:2019-04-24 23:39:38
【问题描述】:
我正在研究使用 python 构建编译器,我正在尝试创建文本中所有小写单词的列表,然后生成BigramCollocationFinder,我们可以使用它来查找双连词,它们是成对的单词。
这些二元组是使用 nltk.metrics 包中的关联测量函数找到的。
我正在从“Python 3 Text Processing with NLTK 3 Cookbook”练习,我发现了这个示例代码:
from nltk.corpus import webtext
from nltk.collocations import BigramCollocationFinder
from nltk.metrics import BigramAssocMeasures
words = [w.lower() for w in webtext.words('grail.txt')]
bcf = BigramCollocationFinder.from_words(words)
bcf.nbest(BigramAssocMeasures.likelihood_ratio, 4)
我被困在:
bcf.nbest(BigramAssocMeasures.likelihood_ratio, 4)
likelihood_ratio, 4
这里指的是相似度,或者在这段代码中是什么意思。
我们将非常感谢您对此事的任何指导。
【问题讨论】:
标签: python-3.x nltk cookbook