SPSS Statistics

 View Only
  • 1.  SPSS Stats TEXTANALYSIS Python extension

    Posted Thu August 15, 2024 01:39 PM

    I am trying to run this for a demo, however I keep running into an error asking for a NLTK download for python 3 which I have and it still wont recognize. I'm not sure if this extension no longer works or If I did something wrong. I am looking to troubleshoot this. 



    ------------------------------
    Kyle Shaw
    ------------------------------


  • 2.  RE: SPSS Stats TEXTANALYSIS Python extension

    Posted Thu August 15, 2024 01:52 PM

    Uninstall scipy & see if that works.



    ------------------------------
    Art Jack
    ------------------------------



  • 3.  RE: SPSS Stats TEXTANALYSIS Python extension

    Posted Thu August 15, 2024 04:52 PM
    I'm assuming that you have the latest version from the Extension Hub (1.5.0).  If not, update to that one.

    The authors of numpy, which is used by NLTK, recently released a major upgrade to version 2.0.0 (now 2.0.1) and thereby broken a number of packages.  If you have that version, it may need to be rolled back.  However, the NLTK package should have been installed with STATS TEXTANALYSIS.

    Please post the exact message you are getting.  You might also try running this in a syntax window (Run > All in that window).

    begin program python.
    import NLTK
    print(NLTK)
    end program.


    --





  • 4.  RE: SPSS Stats TEXTANALYSIS Python extension

    Posted Wed August 21, 2024 11:07 AM
    Edited by Kyle Shaw Wed August 21, 2024 11:08 AM

    This is the error message I am getting. I also tried uninstalling SPSS and reinstalling everything and same issue. I also tried running that script in the syntax editor and nothing happened.



    ------------------------------
    Kyle Shaw
    ------------------------------



  • 5.  RE: SPSS Stats TEXTANALYSIS Python extension
    Best Answer

    Posted Wed August 21, 2024 04:35 PM
      |   view attached
    Just 3 days ago as of this writing, the punkt_tab data module became a requirement of nltk 3.8.2 due to a security issue, so STATS TEXTANALYSIS requires an update to download that module.  nltk also suffers from the numpy 2.0 problem and requires an older version of numpy.

    So do the following.
    1. Install STATS PACKAGE INSTALL via Extensions > Extension Hub if you don't already have it.
    2. Use it (on the Extensions menu) to install numpy version 1.26.4
    3. Open a syntax window in SPSS and run the following code (select all these
    lines and use Run > All)

    begin program python.
    import nltk

    nltk.download()
    end program.

    This will open a window listing the available data modules for NLTK.
    It tends to come up behind the other windows, so look around for it :-(
    4. Click on the All menu at the top of that window.  Find punkt_tab and click to install it.
    5. Close that window, and you should be good to go.

    We will get STATS_TEXTANALYSIS updated to include this new module in the list of automatically installed packages, but the interactive install, which only has to be done once, will get this set up faster.

    I have attached a screenshot showing some of the basic output from TEXTANALYSIS applied to an election survey.


    --