【问题标题】:Connection error using Python wrapper for Stanford CoreNLP tools v3.4.1使用 Python 包装器的斯坦福 CoreNLP 工具 v3.4.1 连接错误
【发布时间】:2016-12-21 10:15:12
【问题描述】:

我一直在尝试使用 stanford-corenlp-python,它是一个使用 this github repo 的 python 包装器。

但是,在存储结果时出现以下错误:

    Traceback (most recent call last):
  File "client.py", line 14, in <module>
    result = nlp.parse("Hello world!  It is so beautiful.")
  File "client.py", line 11, in parse
    return json.loads(self.server.parse(text))
  File "/home/kenden/deeshacodes/stanford-corenlp-python/jsonrpc.py", line 934, in __call__
    return self.__req(self.__name, args, kwargs)
  File "/home/kenden/deeshacodes/stanford-corenlp-python/jsonrpc.py", line 906, in __req
    raise RPCTransportError(err)
jsonrpc.RPCTransportError: [Errno 111] Connection refused

我该如何解决这个问题?另外,有没有其他方法可以在python中使用coreNLP?

【问题讨论】:

    标签: python stanford-nlp


    【解决方案1】:

    也许你可以试试这个stanfordcorenlp

    这很简单。

    from stanfordcorenlp import StanfordCoreNLP
    
    nlp = StanfordCoreNLP(r'G:/JavaLibraries/stanford-corenlp-full-2016-10-31/')
    
    sentence = 'Guangdong University of Foreign Studies is located in Guangzhou.'
    print 'Tokenize:', nlp.word_tokenize(sentence)
    print 'Part of Speech:', nlp.pos_tag(sentence)
    print 'Named Entities:', nlp.ner(sentence)
    print 'Constituency Parsing:', nlp.parse(sentence)
    print 'Dependency Parsing:', nlp.dependency_parse(sentence)
    

    虽然方便,但不如原生 Python 包装器稳定。 “该项目只是一个包装器,用于解析从 Java Server 后端请求的 json 数据。”

    【讨论】:

      【解决方案2】:

      这有点无法回答,但您是否考虑过使用 CoreNLP 服务器?例如,herehere?您还可以直接向正在运行的服务器发出请求并获得 JSON 响应:http://stanfordnlp.github.io/CoreNLP/corenlp-server.html(或 protobuf,如果您喜欢冒险的话)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-02-03
        • 2019-03-17
        • 2012-07-03
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多