JonB last edited by
I haven't installed nltk, but for other toolboxes I've found that setup.py does not work.
Part of this is because the folder structure is different in pythonista than other environments. You don't have write access to ~ for example! you want to keep everything under ~/Documents.
Putting the folder under Site-packages is your best bet. Not sure, but you may need to restart pythonista to get it to reload that folder.
You can also os.chdir to your nltk folder (the one containing the actual nltk.py), and import from there.
You can also append to sys.path with the pointer to the folder containing nltk.py
Ok so i finally got it to allow me to import and open the downloader. Do I need to do any config like set the download path or anything??
ihf last edited by
I have not changed any other settings.
It will not let be dowload brown. How did u guys do that and how did u guys run brown.words()
For example how can i set the NLTKDATA variable to the location of nltk_data
I think I used pythonista to open the data.py file and set it by hand. I think I added it as a path in the list on line 66. Don't know if that is the proper way to do it, but I figured I might have to get a bit hacky to make it work on an iPad.
Thats what I don't know though. Where am I setting it to? How do I find the path of nltk_data
ihf last edited by
My nltk_data directory is at the same level as Documents and NLTK works without setting the NLTKDATA variable.
Using the console I used
import os print os.path.expanduser('~/')
To get the path to the top level of my pythonista install. You can then add on whatever directories you have.
Playing with it some more I've found that it also wants Tkinter. Depending on which packages you load you might get a warning:
Documents/site-packages/nltk/draw/__init__.py:14: UserWarning: nltk.draw package not loaded (please install Tkinter library). warnings.warn("nltk.draw package not loaded "
So text#.dispersion_plot() won't work, but oddly FreqDist(text#).plot(#) does. Evidently plot uses Matplotlib, but dispersion_plot() uses Tkinter.
Spoke too soon. I changed line 456 in nltk.text.py to
from nltk.draw.dispersion import dispersion_plot
And now the dispersion_plot works. Not sure what in the draw package requires Tkinter, but that wasn't it.