[BangPypers] NLTK: Dispersion Plot problem

Gaurav Kalra gvkalra at gmail.com
Wed Aug 18 17:21:11 CEST 2010


> On Tue, Aug 17, 2010 at 3:04 PM, Gaurav Kalra <gvkalra at gmail.com> wrote:
>
> > Hi.
> > I have been trying to learn NLTK (http://www.nltk.org/) following
> > instructions over:
> > http://nltk.googlecode.com/svn/trunk/doc/book/ch01.html
> >
> > The point at which I am stuck is using the function dispersion_plot() (
> >
> >
> http://nltk.googlecode.com/svn/trunk/doc/api/nltk.draw.dispersion-module.html#dispersion_plot
> > )
> >
> > Here is the output of yolk:
> > PyYAML          - 3.09         - active
> > Python          - 2.6.5        - active development
> > (/usr/lib/python2.6/lib-dynload)
> > distribute      - 0.6.10       - active
> > matplotlib      - 1.0.0        - active
> > nltk            - 2.0b9        - active
> > numpy           - 1.4.1        - active
> > pip             - 0.7.2        - active
> > wsgiref         - 0.1.2        - active development (/usr/lib/python2.6)
> > yolk            - 0.4.1        - active
> >
> >
> > I guess that dispersion_plot() requires matplotlib and numpy, which are
> > already active but, running the function is not generating any dispersion
> > graph as showed over here:
> > http://nltk.googlecode.com/svn/trunk/doc/book/ch01.html
> >
>
>
> Have you got any error message.
>
> Which version of NLTK you are using
>
> Try this
>
> from nltk import *
> from nltk.book import *
> text4.dispersion_plot(["citizens", "democracy", "freedom", "duties",
> "America"])
>
> If Numpy and matplotlib is present it will work.
>
>
> --
> **********************************
> JAGANADH G
> http://jaganadhg.freeflux.net/blog
>


Hi Jaganadh,

The NLTK version that I am using is 2.0b9.
Also, I am not getting any error messages.
Here is what I am doing (though every part is not necessary, still posting)
I am able to complete all the exercises, apart from the ones which involves
the interpreter to "display" something graphical. (But I have matplotlib
installed - see yolk -l output)

gvkalra at gvkalra-laptop:~$ cd Desktop/srv/python-environments/
gvkalra at gvkalra-laptop:~/Desktop/srv/python-environments$ source
gotcha/bin/activate
(gotcha)gvkalra at gvkalra-laptop:~/Desktop/srv/python-environments$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from nltk import *
>>> from nltk.book import *
*** Introductory Examples for the NLTK Book ***
Loading text1, ..., text9 and sent1, ..., sent9
Type the name of the text or sentence to view it.
Type: 'texts()' or 'sents()' to list the materials.
text1: Moby Dick by Herman Melville 1851
text2: Sense and Sensibility by Jane Austen 1811
text3: The Book of Genesis
text4: Inaugural Address Corpus
text5: Chat Corpus
text6: Monty Python and the Holy Grail
text7: Wall Street Journal
text8: Personals Corpus
text9: The Man Who Was Thursday by G . K . Chesterton 1908
>>>
text4.dispersion_plot(["citizens","democracy","freedom","duties","America"])
>>>


More information about the BangPypers mailing list