防止Stanford Core NLP Server输出接收到的文本 [英] Preventing Stanford Core NLP Server from outputting the text it receives

查看:71
本文介绍了防止Stanford Core NLP Server输出接收到的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 Stanford CoreNLP 服务器:

java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9001 -timeout 50000

只要收到一些文本,它就会在运行它的shell中输出它.如何防止这种情况发生?

Whenever it receives some text, it outputs it in the shell it is running it. How to prevent this from happening?

这很重要,这是我用来将数据传递到Stanford Core NLP Server的代码:

It that matters, here is the code I use to pass data to Stanford Core NLP Server:

'''
From https://github.com/smilli/py-corenlp/blob/master/example.py
'''
from pycorenlp import StanfordCoreNLP
import pprint

if __name__ == '__main__':
    nlp = StanfordCoreNLP('http://localhost:9000')
    fp = open("long_text.txt")
    text = fp.read()
    output = nlp.annotate(text, properties={
        'annotators': 'tokenize,ssplit,pos,depparse,parse',
        'outputFormat': 'json'
    })
    pp = pprint.PrettyPrinter(indent=4)
    pp.pprint(output)

推荐答案

目前尚无办法,但您是第二个人.因此,它现在在Github代码中,并将进入下一个版本.将来,您应该可以设置-quiet标志,并且服务器将不会写入标准输出.

There's currently not a way to do this, but you're the second person that's asked. So, it's now in the Github code, and will make it into the next release. For the future, you should be able to set the -quiet flag, and the server will not write to standard out.

这篇关于防止Stanford Core NLP Server输出接收到的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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