Pyner 空字典
Pyner empty dictionary
我正在使用Stanford Named Entity Recognizer (NER). The code can be found at Pyner Code
的python接口
import ner
if __name__ == "__main__":
tagger = ner.HttpNER(host='localhost', port=8080)
print tagger.get_entities("University of California is located in California, United States")
print tagger.json_entities("Alice went to the Museum of Natural History.")
假设的输出:
{'LOCATION': ['California', 'United States'], 'ORGANIZATION': ['University of California']}
'{"ORGANIZATION": ["Museum of Natural History"], "PERSON": ["Alice"]}'
问题:为什么我得到空集?
我尝试了以下 solution-Whosebug 但没有成功 我收到以下异常:
Exception in thread "main" java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at java.net.ServerSocket.<init>(ServerSocket.java:128)
at edu.stanford.nlp.ie.NERServer.<init>(NERServer.java:71)
at edu.stanford.nlp.ie.NERServer.main(NERServer.java:331)
首先 运行 套接字模式下的 stanford-ner 服务器使用:
java-mx256m-cp stanford-ner.jaredu.stanford.nlp.ie.NERServer\
-loadClassifier classifiers/english.muc.7class.distsim.crf.ser.gz \
-port 8081 -outputFormat inlineXML.
将代码保存在 windows 批处理文件中,然后 运行 在命令提示符中保存。
您的端口 8080 有问题。这就是我将端口更改为 8081 的原因。在服务器获得 运行ning 后,输入您的 python 代码 -
>>>import ner
>>>tagger = ner.SocketNER(host='localhost', port=8081)
>>>tagger.get_entities("University of California is located in California, United States")
我正在使用Stanford Named Entity Recognizer (NER). The code can be found at Pyner Code
的python接口import ner
if __name__ == "__main__":
tagger = ner.HttpNER(host='localhost', port=8080)
print tagger.get_entities("University of California is located in California, United States")
print tagger.json_entities("Alice went to the Museum of Natural History.")
假设的输出:
{'LOCATION': ['California', 'United States'], 'ORGANIZATION': ['University of California']}
'{"ORGANIZATION": ["Museum of Natural History"], "PERSON": ["Alice"]}'
问题:为什么我得到空集?
我尝试了以下 solution-Whosebug 但没有成功 我收到以下异常:
Exception in thread "main" java.net.BindException: Address already in use
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376)
at java.net.ServerSocket.bind(ServerSocket.java:376)
at java.net.ServerSocket.<init>(ServerSocket.java:237)
at java.net.ServerSocket.<init>(ServerSocket.java:128)
at edu.stanford.nlp.ie.NERServer.<init>(NERServer.java:71)
at edu.stanford.nlp.ie.NERServer.main(NERServer.java:331)
首先 运行 套接字模式下的 stanford-ner 服务器使用:
java-mx256m-cp stanford-ner.jaredu.stanford.nlp.ie.NERServer\ -loadClassifier classifiers/english.muc.7class.distsim.crf.ser.gz \ -port 8081 -outputFormat inlineXML.
将代码保存在 windows 批处理文件中,然后 运行 在命令提示符中保存。
您的端口 8080 有问题。这就是我将端口更改为 8081 的原因。在服务器获得 运行ning 后,输入您的 python 代码 -
>>>import ner
>>>tagger = ner.SocketNER(host='localhost', port=8081)
>>>tagger.get_entities("University of California is located in California, United States")