0

I am trying to get Stanford Dependency Parser setup. However I am getting an Import Error - 'ImportError: cannot import name StanfordDependencyParser'. I tried following instructions from answers to previous posts such as - Stanford Parser and NLTK and Stanford Dependency Parser Setup and NLTK. Nothing seems to be working.

My code is as follows:

>>> import nltk
>>> import os
>>> os.environ['STANFORD_PARSER'] = 'C:\jars'
>>> os.environ['STANFORD_MODELS'] = 'C:\jars'
>>> os.environ['JAVAHOME'] = 'C:\Program Files (x86)\Java\jre1.8.0_66\bin'
>>> from nltk.parse.stanford import StanfordDependencyParser
Traceback (most recent call last):
 File "<pyshell#23>", line 1, in <module>
   from nltk.parse.stanford import StanfordDependencyParser
ImportError: cannot import name StanfordDependencyParser

I am not sure what the issue is. I have updated NLTK to the latest version. I have also tried removing the 'import nltk' in case the error was because I was importing an entity twice.

I'm pretty lost as to how to proceed. I am very new to NLTK and python. Any help would be appreciated. Thank you in advance.

Community
  • 1
  • 1
  • Did you try the solution from http://stackoverflow.com/questions/34053021/stanford-dependency-parser-setup-and-nltk? It's exactly the same problem. Have you reinstalled NLTK to update it to the latest version? – alvas Dec 06 '15 at 00:26
  • If possible, please post the source of where the code snippet come from so that the NLTK devs can take a look at try to correct it =) – alvas Dec 06 '15 at 00:28
  • I've just found the origin of the snippet: http://stackoverflow.com/a/22269678/610569. I've updated most of the answers on that question, please look at the other newer instructions to setup Stanford NLP tools for NLP. – alvas Dec 06 '15 at 03:12
  • Thank you for your reply :) I did update to the latest version of NLTK and try every instruction I could find on setting it up correctly, including the link you mentioned. Unfortunately I was still not able to get rid of that error. I will try the newer instructions you have linked to here -http://stackoverflow.com/a/22269678/610569 . Thank you for your help! –  Dec 07 '15 at 18:16
  • Please try this answer instead. The other one will not work: http://stackoverflow.com/a/34112695/610569 – alvas Dec 07 '15 at 18:19
  • Thank you! I will look into it and post the outcome. Since I was on a deadline, I gave up trying to use the NLTK interface and am now creating my software in Java with Stanford NLP tools. However, I would still like to figure this out and will try it out. Thanks again! –  Dec 07 '15 at 22:03

0 Answers0