0

I want to use Stanford parser with python in nltk package, it works well on pos tagger and NER tagger, but when it comes to parser, it do not work. here is the codes:

import nltk
from nltk.parse import stanford

import os
from nltk.parse import stanford

os.environ['CLASSPATH'] = '/Users/caoyue/PycharmProjects/iepy_/jars'
os.environ['STANFORD_MODELS'] = '/Users/caoyue/PycharmProjects/iepy_/jars'

from nltk.tag.stanford import StanfordPOSTagger
st = StanfordPOSTagger('english-left3words-distsim.tagger')
a=st.tag('What is the airspeed of an unladen swallow ?'.split())
print(a)
from nltk.tag import StanfordNERTagger
st = StanfordNERTagger('english.all.3class.distsim.crf.ser.gz')
b=st.tag('Rami Eid is studying at Stony Brook University in NY'.split())
print(b)
from nltk.parse.stanford import StanfordDependencyParser
dep_parser=StanfordDependencyParser(model_path="/Users/caoyue/PycharmProjects/iepy_/jars/english.all.3class.distsim.crf.ser.gz ")
list(dep_parser.raw_parse("the quick brown fox jumps over the lazy dog"))

enter image description here

And the error is :

enter image description here

I think that the model_path is wrong,how do I set it to be correct?

Hadi
  • 36,233
  • 13
  • 65
  • 124
Yue Cao
  • 61
  • 1
  • 3

1 Answers1

0

I didn't test it, but I assume the trailing space after english.all.3class.distsim.crf.ser.gz leads to some confusion:

model_path="..../english.all.3class.distsim.crf.ser.gz ")

(removed parts of the path for better readability)

acidtobi
  • 1,375
  • 9
  • 13