首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NLTK找不到斯坦福-解析器\..jar!设置CLASSPATH环境变量

NLTK找不到斯坦福-解析器\..jar!设置CLASSPATH环境变量
EN

Stack Overflow用户
提问于 2017-09-25 14:34:58
回答 2查看 8.5K关注 0票数 3

nltk3.2.5中的nltk.parse.stanford。

代码语言:javascript
复制
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")

====>

代码语言:javascript
复制
dep_parser=StanfordDependencyParser(model_path="edu/stanford/nlp/models

init key=lambda model_path: os.path.dirname(model_path) File“/home/fonttian/anaconda3 3/lib/python3.6/site- packages/nltk/parse/stanford.py",第716行,在find_jar_iter LookupError中(‘\n\n%s\n%s’% (div,msg,div)) LookupError:

代码语言:javascript
复制
============================
  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>
===============================
EN

回答 2

Stack Overflow用户

发布于 2017-09-26 04:51:37

您需要将斯坦福解析器的jars和模型添加到CLASSPATH:

  1. 下载斯坦福大学CoreNLP 3.8.0 (以及中国版的jar),可在这里找到:https://stanfordnlp.github.io/CoreNLP/download.html
  2. 将中国模型jar放在斯坦福CoreNLP文件夹中
  3. 将此添加到Python中:os.environ‘’CLASSPATH‘=“/path/ to /stanford-corenlp-满-2017-06-09/*”

我觉得这应该能解决你的问题。

票数 2
EN

Stack Overflow用户

发布于 2019-11-07 08:20:45

请从以下网址下载:

斯坦福/斯坦福-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/

并在代码中指向文件路径。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46407837

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档