dispersion plot

179 views
Skip to first unread message

Coriolis 4s

unread,
Jan 18, 2015, 9:27:50 PM1/18/15
to nltk-users
Attempting to use the dispersion_plot method returns the following:

>>> text8.dispersion_plot('social')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/supc/Py2.7Venv/local/lib/python2.7/site-packages/nltk/text.py", line 445, in dispersion_plot
    dispersion_plot(self, words)
  File "/home/supc/Py2.7Venv/local/lib/python2.7/site-packages/nltk/draw/dispersion.py", line 31, in dispersion_plot
    words.reverse()
AttributeError: 'str' object has no attribute 'reverse'

however:

>>> dir(text8)
['_CONTEXT_RE', '_COPY_TOKENS', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__getitem__', '__hash__', '__init__', '__len__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__unicode__', '__weakref__', '_collocations', '_context', '_num', '_window_size', 'collocations', 'common_contexts', 'concordance', 'count', 'dispersion_plot', 'findall', 'index', 'name', 'plot', 'readability', 'similar', 'tokens', 'unicode_repr', 'vocab']

and

>>> text8.dispersion_plot
<bound method Text.dispersion_plot of <Text: Personals Corpus>>

Previously:

:~$ pip install --upgrade nltk
Downloading/unpacking nltk from https://pypi.python.org/packages/source/n/nltk/nltk-3.0.1.tar.gz#md5=c4f4b7be66d19dd5faf3c8336bb4cec4
  Downloading nltk-3.0.1.tar.gz (961kB): 961kB downloaded
  Running setup.py (path:/home/supc/Py2.7Venv/build/nltk/setup.py) egg_info for package nltk
   
    warning: no files found matching 'Makefile' under directory '*.txt'
    warning: no previously-included files matching '*~' found anywhere in distribution
Installing collected packages: nltk
  Found existing installation: nltk 2.0.4
    Uninstalling nltk:
      Successfully uninstalled nltk
  Running setup.py install for nltk
   
    warning: no files found matching 'Makefile' under directory '*.txt'
    warning: no previously-included files matching '*~' found anywhere in distribution
Successfully installed nltk
Cleaning up...

Any help to remove these error messages would be appreciated. Thanks.

Steven Bird

unread,
Jan 18, 2015, 11:19:58 PM1/18/15
to nltk-users
The dispersion_plot function requires a list of words, not a single word, as documented at:







--
You received this message because you are subscribed to the Google Groups "nltk-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nltk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

orpus...@gmail.com

unread,
Jan 19, 2015, 5:44:37 AM1/19/15
to nltk-users
Was hoping for a slightly more informative error message. Thanks. Any idea to what the errors during installation mean will be helpful too.
Reply all
Reply to author
Forward
0 new messages