Natural Language Processing with Python .dispersion_plot returns nothing

Discussion in 'Python' started by sixtyfourbit, Jun 17, 2013.

  1. sixtyfourbit

    sixtyfourbit Guest

    I'm in the first chapter of Natural Language Processing with Python and am trying to run the example .dispersion_plot. I am using Python 2.7.4 (Anaconda) on Mac OSX 10.8.

    When I load all of the necessary modules and try to create the dispersion plott, I get no return - no plot, no error message, not even a new >>> prompt, just a blinking cursor under the last line I typed. Here is what I've been doing:

    [~]: python
    Python 2.7.4 |Anaconda 1.5.1 (x86_64)| (default, May 9 2013, 12:12:00)
    [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import numpy
    >>> import matplotlib
    >>> import nltk
    >>> 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"])


    ....and nothing. I can't paste it but my cursor is just blinking under my last command with no prompt. So far the other example commands from the chapter (e.g. .concordance) work fine, so I'm guessing the problem is something with numpy or matplotlib. I had a heck of a time getting matplotlib installed correctly (kept getting errors saying that it wasn't installed even whenI had installed it), but since switching to the Anaconda distro, which hadthose prepackaged, I haven't gotten any module errors.

    Any advice??
     
    sixtyfourbit, Jun 17, 2013
    #1
    1. Advertising

  2. sixtyfourbit

    John Gordon Guest

    In <> sixtyfourbit <> writes:

    > When I load all of the necessary modules and try to create the dispersion
    > plott, I get no return - no plot, no error message, not even a new >>>
    > prompt, just a blinking cursor under the last line I typed.


    How long did you wait for results before interrupting the command?
    How large is text4? It might just take a while to process.

    --
    John Gordon A is for Amy, who fell down the stairs
    B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"
     
    John Gordon, Jun 17, 2013
    #2
    1. Advertising

  3. sixtyfourbit

    sixtyfourbit Guest

    I let it run for 5-10 minutes. It's doing this no matter which text I try to run the dispersion plot on


    On Monday, June 17, 2013 12:38:58 PM UTC-4, John Gordon wrote:
    > In <> sixtyfourbit <> writes:
    >
    >
    >
    > > When I load all of the necessary modules and try to create the dispersion

    >
    > > plott, I get no return - no plot, no error message, not even a new >>>

    >
    > > prompt, just a blinking cursor under the last line I typed.

    >
    >
    >
    > How long did you wait for results before interrupting the command?
    >
    > How large is text4? It might just take a while to process.
    >
    >
    >
    > --
    >
    > John Gordon A is for Amy, who fell down the stairs
    >
    > B is for Basil, assaulted by bears
    >
    > -- Edward Gorey, "The Gashlycrumb Tinies"
     
    sixtyfourbit, Jun 17, 2013
    #3
  4. sixtyfourbit

    Peter Otten Guest

    Re: Natural Language Processing with Python .dispersion_plot returnsnothing

    sixtyfourbit wrote:

    > I'm in the first chapter of Natural Language Processing with Python and am
    > trying to run the example .dispersion_plot. I am using Python 2.7.4
    > (Anaconda) on Mac OSX 10.8.
    >
    > When I load all of the necessary modules and try to create the dispersion
    > plott, I get no return - no plot, no error message, not even a new >>>
    > prompt, just a blinking cursor under the last line I typed. Here is what
    > I've been doing:
    >
    > [~]: python
    > Python 2.7.4 |Anaconda 1.5.1 (x86_64)| (default, May 9 2013, 12:12:00)
    > [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
    > Type "help", "copyright", "credits" or "license" for more information.
    >>>> import numpy
    >>>> import matplotlib
    >>>> import nltk
    >>>> 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"])

    >
    > ...and nothing. I can't paste it but my cursor is just blinking under my
    > last command with no prompt. So far the other example commands from the
    > chapter (e.g. .concordance) work fine, so I'm guessing the problem is
    > something with numpy or matplotlib. I had a heck of a time getting
    > matplotlib installed correctly (kept getting errors saying that it wasn't
    > installed even when I had installed it), but since switching to the
    > Anaconda distro, which had those prepackaged, I haven't gotten any module
    > errors.
    >
    > Any advice??


    The dispersion_plot() method uses pylab.show() to display the data (in
    another window). Only when you close that window the interactive interpreter
    becomes responsive again.

    If you didn't overlook that window: do you run into the same problem with

    >>> import pylab
    >>> pylab.plot([1, 2, 3], [3, 1, 2])

    [<matplotlib.lines.Line2D object at 0x2d713d0>]
    >>> pylab.show()


    ? If so, choose another backend. I've not tried, but it seems straight-
    forward, see <http://matplotlib.org/faq/usage_faq.html#what-is-a-backend>
     
    Peter Otten, Jun 17, 2013
    #4
  5. Re: Natural Language Processing with Python .dispersion_plotreturns nothing

    On Mon, 17 Jun 2013 09:31:18 -0700, sixtyfourbit wrote:

    > I'm in the first chapter of Natural Language Processing with Python and
    > am trying to run the example .dispersion_plot. I am using Python 2.7.4
    > (Anaconda) on Mac OSX 10.8.
    >
    > When I load all of the necessary modules and try to create the
    > dispersion plott, I get no return - no plot, no error message, not even
    > a new >>> prompt, just a blinking cursor under the last line I typed.
    > Here is what I've been doing:

    [...]
    > ...and nothing. I can't paste it but my cursor is just blinking under my
    > last command with no prompt.


    I expect that the plot is shown in a graphical window opened somewhere on
    screen, perhaps *under* the terminal window where you can't see it. Or
    maybe even a dialog box showing an error. Until that window or dialog is
    closed, the dispersion_plot command hasn't finished and Python will just
    wait forever.


    --
    Steven
     
    Steven D'Aprano, Jun 18, 2013
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jelle Feringa // EZCT / Paris

    OCAMl a more natural extension language for python?

    Jelle Feringa // EZCT / Paris, Jan 17, 2005, in forum: Python
    Replies:
    4
    Views:
    501
  2. Andrew Gwozdziewycz

    Natural Language Date Processing.

    Andrew Gwozdziewycz, Feb 7, 2006, in forum: Python
    Replies:
    9
    Views:
    582
    John McMonagle
    Feb 9, 2006
  3. Steven Bird
    Replies:
    1
    Views:
    401
    tool69
    May 26, 2007
  4. Fred
    Replies:
    3
    Views:
    361
    red floyd
    Sep 25, 2007
  5. Prateek
    Replies:
    1
    Views:
    355
    Alejandro E. Ciniglio
    Aug 14, 2009
Loading...

Share This Page