Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

三元组抽取是报错了,不知道你有没有遇到?网上没有找到解决方法 #3

Open
jxz542189 opened this issue May 7, 2019 · 3 comments

Comments

@jxz542189
Copy link

Traceback (most recent call last):
File "/root/PycharmProjects/entity_extract/test.py", line 82, in
SVOs += ht2.triple_extraction(sent.strip())
File "/root/anaconda3/envs/tensorflow/lib/python3.6/site-packages/harvesttext-0.5.4-py3.6.egg/harvesttext/harvesttext.py", line 577, in triple_extraction
arcs = self.dependency_parse(sent, standard_name, stopwords)
File "/root/anaconda3/envs/tensorflow/lib/python3.6/site-packages/harvesttext-0.5.4-py3.6.egg/harvesttext/harvesttext.py", line 550, in dependency_parse
sentence = HanLP.parseDependency(sent2)
jpype._jexception.NoSuchElementExceptionPyRaisable: java.util.NoSuchElementException

@blmoistawinde
Copy link
Owner

根据错误信息,问题是出在我调用的pyhanlp的接口上。
建议首先检查一下pyhanlp的安装情况,可以尝试重装我本人使用的版本:

pip uninstall pyhanlp
pip install pyhanlp==0.1.44

再试试看。

如果还是不行的情况:
pyhanlp依赖于hanlp这个JAVA库的代码,这个错误好像就是没有找到对应的JAVA元素。
所以,建议检查一下对应的JAVA版hanlp的安装情况,命令行里输入:

hanlp -v

正常情况下会显示版本,类似:

jar  1.6.7: D:\Program files\Anaconda2\envs\py36\lib\site-packages\pyhanlp\static\hanlp-1.6.7.jar
data 1.6.7: D:/Program files/Anaconda2/envs/py36/lib/site-packages/pyhanlp/static\data
config    : D:\Program files\Anaconda2\envs\py36\lib\site-packages\pyhanlp\static\hanlp.properties

看看有没有问题。如果这里也没有问题,考虑参照这个教程,配置跟我一样的hanlp版本。

希望能够解决你的问题

@jxz542189
Copy link
Author

没有解决,如果不是用harvesttext直接使用HanLP.parseDependency是正常的,相当奇怪。大神,要是能对各个模块都有说明文档就更好了,真的是不错的项目,厉害

@blmoistawinde
Copy link
Owner

最近在用另一台电脑的时候,发现了同样的问题。然后发现是hanLP自身的一个问题,参考这个issue后我修复了这个问题。
只要下载这个文件
https://github.com/hankcs/HanLP/files/3357416/hanlp-1.7.4.jar.zip
将解压后的jar文件覆盖掉
[你的python环境]/Lib/site-packages/pyhanlp/static/hanlp-1.7.4.jar
即可。
希望也能解决你的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants