Note that text.collocations() is just a convenience function to
demonstrate various operations on texts. For serious work with
collocations, you can read the implementation of that collocations()
method, or read the collocations howto:
http://code.google.com/p/nltk/source/browse/trunk/nltk/nltk/text.py
http://nltk.googlecode.com/svn/trunk/doc/howto/collocations.html
> Trying the first exercise yields the following result on my machine:
>
>>>> import nltk
>>>> from nltk.collocations import *
>>>> finder =
>>>> BigramCollocationFinder.from_words(nltk.corpus.genesis.words('english-web.txt'))
>>>> finder.nbest(bigram_measures.pmi, 10)
>
> Traceback (most recent call last):
> File "<pyshell#8>", line 1, in <module>
> finder.nbest(bigram_measures.pmi, 10)
> NameError: name 'bigram_measures' is not defined
bigram_measures is defined at the top of the howto document:
bigram_measures = nltk.collocations.BigramAssocMeasures()
-Steven Bird
bigram_measures = nltk.collocations.BigramAssocMeasures()at the top of the Collocations HowTo at:
http://nltk.googlecode.com/svn/trunk/doc/howto/collocations.html All the best, David.
Fixed now, sorry. The published howto documents were slightly out of date.
-Steven Bird