Nlp NLTK无法找到stanford parser\.jar!设置CLASSPATH环境变量
nltk3.2.5中的nltk.parse.stanfordNlp NLTK无法找到stanford parser\.jar!设置CLASSPATH环境变量,nlp,nltk,stanford-nlp,Nlp,Nltk,Stanford Nlp,nltk3.2.5中的nltk.parse.stanford 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
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")
==>
/lexparser/chinesePCFG.ser.gz“)
文件“/home/fonttian/anaconda3/lib/python3.6/site-
packages/nltk/parse/stanford.py”,第52行,在init
key=lambda模型路径:os.path.dirname(模型路径)
文件“/home/fonttian/anaconda3/lib/python3.6/site-
packages/nltk/internals.py”,第716行,在find_jar_iter中
引发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>
===============================
============================
NLTK无法找到stanford parser\.jar!请设置类路径
环境变量。
有关更多信息,请参阅stanford parser\.jar:
===============================
您需要将Stanford解析器的JAR和模型添加到类路径中:
os.environ['CLASSPATH'] = "/path/to/stanford-corenlp-full-2017-06-09/*"
并在代码中指出文件路径。I do it“import os.environ['CLASSPATH']=“fonttian/home/NLP/stanford-corenlp-full-2017-06-09/*”但什么也没发生,“NLTK无法找到stanford parser\.jar!设置CLASSPATH环境变量。有关stanford parser\.jar的更多信息,请参阅:事实上,当我使用“2015”时,在“stanford-corenlp-full-2017-06-09”中找不到stanford parser\.jar,错误:错误: 找不到或无法加载主类 edu.stanford.nlp.parser.lexparser.LexicalizedParserfrom nltk.parse.stanford import*import os.environ['CLASSPATH']=“home/fonttian/nlp/stanford-parser/stanford-dependencParser('/home/fonttian/nlp/stanford-2015/chinese distsim.tager',“/home/fonttian/nlp/stanford-2015/stanford parser.jar”)dep parser.raw自然语言处理的测试句子")请看
os.environ['CLASSPATH'] = "/path/to/stanford-corenlp-full-2017-06-09/*"