Reputation: 31
the nltk.parse.stanford in nltk3.2.5.
from nltk.parse.stanford import *
# CoreNLPServer = CoreNLPServer(path_to_jar="/home/fonttian/NLP/stanford/")
# dep_parser=StanfordDependencyParser(model_path="/home/fonttian/NLP/stanford/stanford-chinese-corenlp-2017-06-09-models/edu/stanford/nlp/models/lexparser/chinesePCFG.ser.gz")
====>
dep_parser=StanfordDependencyParser(model_path="edu/stanford/nlp/models
/lexparser/chinesePCFG.ser.gz") File "/home/fonttian/anaconda3/lib/python3.6/site- packages/nltk/parse/stanford.py", line 52, in init key=lambda model_path: os.path.dirname(model_path) File "/home/fonttian/anaconda3/lib/python3.6/site- packages/nltk/internals.py", line 716, in find_jar_iter raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div)) LookupError:
============================
NLTK was unable to find stanford-parser\.jar! Set the CLASSPATH
environment variable.
For more information, on stanford-parser\.jar, see:
<https://nlp.stanford.edu/software/lex-parser.shtml>
===============================
Upvotes: 3
Views: 9490
Reputation: 9338
Download them from:
stanford/stanford-parser.jar.zip
http://www.java2s.com/Code/Jar/s/Downloadstanfordparserjar.htm
stanford-parser-3.5.2-models.jar
http://central.maven.org/maven2/edu/stanford/nlp/stanford-parser/3.5.2/
And point the file paths in code.
Upvotes: 0
Reputation: 8739
You need to add the jars for the Stanford parser and the models to your CLASSPATH:
download Stanford CoreNLP 3.8.0 (and the Chinese models jar) available here: https://stanfordnlp.github.io/CoreNLP/download.html
place the Chinese models jar in the Stanford CoreNLP folder
add this to your Python:
os.environ['CLASSPATH'] = "/path/to/stanford-corenlp-full-2017-06-09/*"
I think that should fix your issue.
Upvotes: 3