首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >依赖项使用python解析大型文本文件

依赖项使用python解析大型文本文件
EN

Stack Overflow用户
提问于 2019-01-31 02:49:24
回答 1查看 632关注 0票数 0

我试图解析一个大的txt文件(大约2000句)。当我想设置model_path时,我会得到这样的按摩:

NLTK找不到斯坦福-parser.jar!设置CLASSPATH环境变量。此外,当我将CLASSPATH设置为此文件时,还会出现另一条消息: NLTK无法找到斯坦福解析器-(\d+)(.(\d+))+- comes s.jar!设置CLASSPATH环境变量。

你能帮我解决吗?这是我的密码:

进口nltk 从nltk.parse.stanford导入StanfordDependencyParser model_path="edu\stanford\lp\models\lexparser\englishPCFG.ser.gz") = dependency_parser =StanfordDependencyParser

=========================================================================== NLTK找不到斯坦福-parser.jar!设置CLASSPATH环境变量。

有关斯坦福-parser.jar的更多信息,请参见:

https://nlp.stanford.edu/software/lex-parser.shtml

导入操作系统 Os.environ‘’CLASSPATH‘=“斯坦福-corenlp-2018-10-05/*” model_path="edu\stanford\lp\models\lexparser\englishPCFG.ser.gz") = dependency_parser =StanfordDependencyParser

=========================================================================== NLTK找不到斯坦福-parser.jar!设置CLASSPATH环境变量。

有关斯坦福-parser.jar的更多信息,请参见:

https://nlp.stanford.edu/software/lex-parser.shtml

Os.environ‘’CLASSPATH‘= "stanford-corenlp-full-2018-10-05/stanford-parser-full-2018-10-17/stanford-parser.jar“

model_path="stanford-corenlp-full-2018-10-05/stanford-parser-full-2018-10-17/edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz") ( >>> dependency_parser =StanfordDependencyParser)

NLTK找不到斯坦福-解析器-(\d+)(.(\d+))+-Models.jar!设置CLASSPATH环境变量。

有关斯坦福解析器-(\d+)(.(\d+))+- more s.jar的更多信息,请参见:https://nlp.stanford.edu/software/lex-parser.shtml

EN

回答 1

Stack Overflow用户

发布于 2019-01-31 05:19:48

您应该获得一个新的stanfordnlp依赖解析器,该解析器是Python的本机!它在CPU上的运行速度将比GPU慢,但它仍然应该运行得相当快。

只需运行pip install stanfordnlp安装即可。

代码语言:javascript
运行
复制
import stanfordnlp
stanfordnlp.download('en')   # This downloads the English models for the neural pipeline
nlp = stanfordnlp.Pipeline() # This sets up a default neural pipeline in English
doc = nlp("Barack Obama was born in Hawaii.  He was elected president in 2008.")
doc.sentences[0].print_dependencies()

还有一个有用的命令行工具:

代码语言:javascript
运行
复制
python -m stanfordnlp.run_pipeline -l en example.txt

详细信息如下:https://stanfordnlp.github.io/stanfordnlp/

GitHub:https://github.com/stanfordnlp/stanfordnlp

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

https://stackoverflow.com/questions/54452603

复制
相关文章

相似问题

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