omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Installing NLTK

    Pythonista
    4
    22
    19382
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ihf
      ihf last edited by

      I used the version of shellista that includes the pdown command (not pipista). Then after unzipping and untaring, I moved everything to an nltk directory in Documents (within the Pythonista app). I was then able to import nltk and run samples from the book. I found it easier to move things around on the iPad using Diskaid from my Mac but you should be able to create the directories and move things from within Pythonista.

      1 Reply Last reply Reply Quote 0
      • karthikmaiya
        karthikmaiya last edited by

        So u moved the entire nltk-2.0.4 folder to another folder named nltk and just opened up the console and run your commands?

        1 Reply Last reply Reply Quote 0
        • Rothrock42
          Rothrock42 last edited by

          @karthikmaiya, are you using the latest (1.5) version of pythonista? Do you have site-packages > nltk-2.0.4 > nltk or do you have site-packages > nltk or something else? I had to move things around a bit (using shellista). Just having the simple nltk right at the top level was the easiest way to get it working for me. I'm away from my iPad until tonight, so I can't look at all the details.

          1 Reply Last reply Reply Quote 0
          • karthikmaiya
            karthikmaiya last edited by

            Yes i am on 1.5. My site-packages is separate from the folder nltk-2.0.4. So my nltk-2.0.4 folder is on the top level.

            1 Reply Last reply Reply Quote 0
            • ihf
              ihf last edited by

              I have a folder nltk at the top level (same level as pipista.py). Within the nltk folder are all the files and folders that were inside the nltk-2.0.4 folder.

              1 Reply Last reply Reply Quote 0
              • karthikmaiya
                karthikmaiya last edited by

                So how did u then import nltk. It still does not work for me. Did you have to run any setup scripts such as setuptools? And if so can you give me any specifics. I really want to start going through the book.

                1 Reply Last reply Reply Quote 0
                • JonB
                  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

                  1 Reply Last reply Reply Quote 0
                  • karthikmaiya
                    karthikmaiya last edited by

                    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??

                    1 Reply Last reply Reply Quote 0
                    • ihf
                      ihf last edited by

                      I have not changed any other settings.

                      1 Reply Last reply Reply Quote 0
                      • karthikmaiya
                        karthikmaiya last edited by

                        It will not let be dowload brown. How did u guys do that and how did u guys run brown.words()

                        1 Reply Last reply Reply Quote 0
                        • karthikmaiya
                          karthikmaiya last edited by

                          For example how can i set the NLTKDATA variable to the location of nltk_data

                          1 Reply Last reply Reply Quote 0
                          • Rothrock42
                            Rothrock42 last edited by

                            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.

                            1 Reply Last reply Reply Quote 0
                            • karthikmaiya
                              karthikmaiya last edited by

                              Thats what I don't know though. Where am I setting it to? How do I find the path of nltk_data

                              1 Reply Last reply Reply Quote 0
                              • ihf
                                ihf last edited by

                                My nltk_data directory is at the same level as Documents and NLTK works without setting the NLTKDATA variable.

                                1 Reply Last reply Reply Quote 0
                                • Rothrock42
                                  Rothrock42 last edited by

                                  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.

                                  1 Reply Last reply Reply Quote 0
                                  • Rothrock42
                                    Rothrock42 last edited by

                                    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.

                                    1 Reply Last reply Reply Quote 0
                                    • Rothrock42
                                      Rothrock42 last edited by

                                      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.

                                      1 Reply Last reply Reply Quote 0
                                      • First post
                                        Last post
                                      Powered by NodeBB Forums | Contributors