小编Fah*_*zal的帖子

如何在python nltk中获得n-gram搭配和关联?

这个文件中,使用的例子nltk.collocations.BigramAssocMeasures(),BigramCollocationFinder,nltk.collocations.TrigramAssocMeasures(),和TrigramCollocationFinder.

对于bigram和trigram,有基于pmi的示例方法find nbest.例:

finder = BigramCollocationFinder.from_words(
...     nltk.corpus.genesis.words('english-web.txt'))
>>> finder.nbest(bigram_measures.pmi, 10)
Run Code Online (Sandbox Code Playgroud)

我知道BigramCollocationFinderTrigramCollocationFinder继承自AbstractCollocationFinder.While BigramAssocMeasures()TrigramAssocMeasures()继承自NgramAssocMeasures.

如何使用该方法(例如nbest())在AbstractCollocationFinderNgramAssocMeasures4克,5克,6克,...,的n-gram(例如使用二元和三元语法容易)?

我应该创建继承的类AbstractCollocationFinder吗?

谢谢.

python nlp nltk n-gram collocation

6
推荐指数
2
解决办法
6775
查看次数

标签 统计

collocation ×1

n-gram ×1

nlp ×1

nltk ×1

python ×1