繁体   English   中英

Python PyNER库不提供任何输出

[英]Python PyNER library doesn't give any output

我想使用pyNER库来从句子中提取名称。

我在ubuntu机器上安装了ner,然后为测试编写了以下脚本。

>>> import ner
>>> tagger = ner.HttpNER(host='localhost', port=80)
>>> tagger.json_entities("Alice went to the Museum of Natural History.")

通常,我必须获得以下输出:

'{"ORGANIZATION": ["Museum of Natural History"], "PERSON": ["Alice"]}'

但是我什么也没得到:

{}

如何解决此问题?

谢谢,

看起来有问题( https://github.com/dat/pyner/issues/2

为了使其正常工作,您必须指定输出格式(slashTags):

tagger = ner.SocketNER(host='localhost',port=80, output_format='slashTags')

另外,我会考虑使用80以外的其他端口,因为通常用于网络流量。

另外,如果这不起作用,请使用SocketNER而不是HttpNER并按照NER的常见问题解答中的说明进行操作

http://nlp.stanford.edu/software/crf-faq.shtml#cc

cp stanford-ner.jar stanford-ner-with-classifier.jar 
jar -uf stanford-ner-with-classifier.jar classifiers/english.all.3class.distsim.crf.ser.gz 
java -mx500m -cp stanford-ner-with-classifier.jar edu.stanford.nlp.ie.NERServer -port 9191 -loadClassifier classifiers/english.all.3class.distsim.crf.ser.gz &

然后在你的python脚本中

import ner
tagger = ner.SocketNER(host='localhost',port=9191, output_format='slashTags')
print tagger.get_entities("University of California is located in California, United States")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM