gpt4 book ai didi

nlp - NLTK 无法找到 stanford-parser\.jar!设置 CLASSPATH 环境变量

转载 作者:行者123 更新时间:2023-12-04 03:09:29 24 4
gpt4 key购买 nike

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-06-09-models/edu/stanford/nlp/models/lexparser/chinesePCFG.ser.gz")

====>

dep_parser=StanfordDependencyParser(model_path="edu/stanford/nlp/models

/lexparser/chinesePCFG.ser.gz") 文件“/home/fontian/anaconda3/lib/python3.6/site-packages/nltk/parse/stanford.py”,第 52 行,在 init 中 key=lambda 模型路径:os.path.dirname(模型路径) 文件“/home/fontian/anaconda3/lib/python3.6/site-packages/nltk/internals.py”,第 716 行,在 find_jar_iter 中 引发 LookupError('\n\n%s\n%s\n%s' % (div, msg, div)) 查找错误:

============================
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>
===============================

最佳答案

您需要将 Stanford 解析器和模型的 jar 添加到您的 CLASSPATH:

  1. 在此处下载 Stanford CoreNLP 3.8.0(和中文模型 jar):https://stanfordnlp.github.io/CoreNLP/download.html

  2. 将中文模型 jar 放在 Stanford CoreNLP 文件夹中

  3. 将此添加到您的 Python 中:

    os.environ['CLASSPATH'] = "/path/to/stanford-corenlp-full-2017-06-09/*"

我认为这应该可以解决您的问题。

关于nlp - NLTK 无法找到 stanford-parser\.jar!设置 CLASSPATH 环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46407837/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com