我正在运行一个斯坦福核心自然语言处理 http://stanfordnlp.github.io/CoreNLP/ server:
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9001 -timeout 50000
每当它收到一些文本时,它就会在运行它的 shell 中输出它。如何防止这种情况发生?
重要的是,这是我用来将数据传递到斯坦福核心 NLP 服务器的代码:
'''
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
标志,并且服务器不会写入标准输出。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)