我正在运行一个斯坦福大学CoreNLP服务器:
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9001 -timeout 50000每当它收到一些文本时,它就会将它输出到正在运行的shell中。如何防止这种情况发生?
重要的是,下面是我用来向Stanford 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)发布于 2016-04-22 06:55:53
目前还没有办法做到这一点,但你是第二个被问到的人。因此,它现在在Github代码中,并将进入下一个版本。将来,您应该能够设置-quiet标志,并且服务器不会写入标准输出。
发布于 2016-05-27 18:07:40
我问了同一个问题,可以提供一些解决办法。我目前正在虚拟机中运行服务器。为了防止现在的日志输出,我使用2&>1 >/dev/null管道参数运行它:
java -mx6g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -prettyPrint false 2&>1 >/dev/null这在等待3.6.1之前提供了相当大的性能提升。
https://stackoverflow.com/questions/36780358
复制相似问题