无法在python模块中使用Stanford NER [英] Unable to use Stanford NER in python module

查看:225
本文介绍了无法在python模块中使用Stanford NER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Python Stanford NER模块,但一直出现错误,我在互联网上搜索了它,但一无所获.这是有错误的基本用法.

I want to use Python Stanford NER module but keep getting an error,I searched it on internet but got nothing. Here is the basic usage with error.

import ner
tagger = ner.HttpNER(host='localhost', port=8080)
tagger.get_entities("University of California is located in California,   

United States")

错误

Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
tagger.get_entities("University of California is located in California, United States")
File "C:\Python27\lib\site-packages\ner\client.py", line 81, in get_entities
tagged_text = self.tag_text(text)
File "C:\Python27\lib\site-packages\ner\client.py", line 165, in tag_text
c.request('POST', self.location, params, headers)
File "C:\Python27\lib\httplib.py", line 1057, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 1097, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 1053, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 897, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 859, in send
self.connect()
File "C:\Python27\lib\httplib.py", line 836, in connect
self.timeout, self.source_address)
File "C:\Python27\lib\socket.py", line 575, in create_connection
raise err
error: [Errno 10061] No connection could be made because the target machine actively refused it

使用装有最新Java的Windows 10

Using windows 10 with latest Java installed

推荐答案

  • Python Stanford NER模块是Stanford NER的包装, 允许您运行python命令以使用NER服务.
  • NER 服务是Python模块的单独实体.它是一个Java 程序.要通过python或其他任何方式访问此服务,您需要 首先需要启动服务.
  • 有关如何启动Java的详细信息 程序/服务可以在这里找到- http://nlp.stanford.edu/software/CRF-NER.shtml
  • NER自带 Windows的.bat文件和Unix/linux的.sh文件.我认为 这些文件开始GUI

    • The Python Stanford NER module is a wrapper for the Stanford NER that allows you to run python commands to use the NER service.
    • The NER service is a separate entity to the Python module. It is a Java program. To access this service, via python, or any other way, you first need to start the service.
    • Details on how to start the Java Program/service can be found here - http://nlp.stanford.edu/software/CRF-NER.shtml
    • The NER comes with a .bat file for windows and a .sh file for unix/linux. I think these files start the GUI

      要在没有GUI的情况下启动服务,应运行类似于以下命令:
      java -mx600m -cp stanford-ner.jar edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier classifiers/english.all.3class.distsim.crf.ser.gz
      这将运行NER jar,设置内存并设置要使用的分类器. (我认为您必须在Stanford NER目录中才能运行此程序)

      To start the service without the GUI you should run a command similar to this:
      java -mx600m -cp stanford-ner.jar edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier classifiers/english.all.3class.distsim.crf.ser.gz
      This runs the NER jar, sets the memory, and sets the classifier you want to use. (I think youll have to be in the Stanford NER directory to run this)

      一旦NER程序运行,您将能够运行python代码并查询NER.

      Once the NER program is running then you will be able to run your python code and query the NER.

      这篇关于无法在python模块中使用Stanford NER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆