1

I am new to dependecy parsing and maybe this error might be very easy to fix. I am trying to perform dependency parsing on statements in order to find out the focus of specific words. I found following links:

How do I do dependency parsing in NLTK?

If I try the above link then I am getting,

LookupError: 

===========================================================================
NLTK was unable to find the java file!
Use software specific configuration paramaters or set the JAVAHOME environment variable.
===========================================================================

The second link I tried was:

https://github.com/Lynten/stanford-corenlp

Following is my implementation:

from pycorenlp import StanfordCoreNLP

nlp = StanfordCoreNLP('http://localhost:9000')
sentence='I shot an elephant in my sleep'
print 'Dependency Parsing:', nlp.dependency_parse(sentence)
nlp.close()

But I am getting AttributeError: StanfordCoreNLP instance has no attribute 'dependency_parse'

If there are other methods which are easier, then also I am open to them. Thank you.

amy
  • 342
  • 1
  • 5
  • 18
  • 1
    is CoreNLP actually running on localhost? – 0x5050 Aug 27 '18 at 09:27
  • @PradipPramanick I used the CoreNLP for sentiment analysis and it worked just fine, if that's what you are asking. If you are asking me if the CoreNLP server is working, then yes it is also working. – amy Aug 29 '18 at 00:06
  • @PradipPramanick Example: `def senti_corenlp(text): output = nlp.annotate(text, properties={ 'annotators': 'sentiment', 'outputFormat': 'json' }) for s in output["sentences"]: return s["sentimentDistribution"]` So I changed the 'annotators' to 'depparse' and got the result. But I can't interpret it. Too long to show as well. – amy Aug 29 '18 at 00:27
  • @PradipPramanick `from pycorenlp import StanfordCoreNLP nlp = StanfordCoreNLP('http://localhost:9000') text='I shot an elephant in my sleep' output = nlp.annotate(text, properties={ 'annotators': 'depparse', 'outputFormat': 'json' }) print output` This is what I tried and worked. – amy Aug 29 '18 at 00:32

0 Answers0