在这个文件中,使用的例子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)
我知道BigramCollocationFinder并TrigramCollocationFinder继承自AbstractCollocationFinder.While BigramAssocMeasures()和TrigramAssocMeasures()继承自NgramAssocMeasures.
如何使用该方法(例如nbest())在AbstractCollocationFinder与NgramAssocMeasures4克,5克,6克,...,的n-gram(例如使用二元和三元语法容易)?
我应该创建继承的类AbstractCollocationFinder吗?
谢谢.