我试图运行pycorenlp,它是Stanford CoreNLP的Python包装器,使用^{
我首先推出了斯坦福大学的CoreNLP:
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 50000
然后运行:
^{pr2}$令人惊讶的是,这没有输出:
text_input: this is a test.
text_output: {}
为什么?在
如果我添加^{text_output
不再是空的:
text_input = 'this is a test.'
print('text_input: {0}'.format(text_input))
text_output = nlp.annotate(text_input, properties={
'annotators': 'tokenize,ssplit',
'outputFormat': 'json'
})
print('text_output: {0}'.format(text_output))
输出:
text_input: this is a test.
text_output: {u'sentences': [{u'parse': u'SENTENCE_SKIPPED_OR_UNPARSABLE', u'index': 0, u'tokens': [{u'index': 1, u'word': u'this', u'after': u' ', u'characterOffsetEnd': 4, u'characterOffsetBegin': 0, u'originalText': u'this', u'before': u''}, {u'index': 2, u'word': u'is', u'after': u' ', u'characterOffsetEnd': 7, u'characterOffsetBegin': 5, u'originalText': u'is', u'before': u' '}, {u'index': 3, u'word': u'a', u'after': u' ', u'characterOffsetEnd': 9, u'characterOffsetBegin': 8, u'originalText': u'a', u'before': u' '}, {u'index': 4, u'word': u'test', u'after': u'', u'characterOffsetEnd': 14, u'characterOffsetBegin': 10, u'originalText': u'test', u'before': u' '}, {u'index': 5, u'word': u'.', u'after': u'', u'characterOffsetEnd': 15, u'characterOffsetBegin': 14, u'originalText': u'.', u'before': u''}]}]}
overview of the annotator dependencies似乎在说我应该能够单独使用^{
你说得对,如果唯一提供的注释器是“tokenize”,那么API似乎没有响应。它应该默认为
PTBTokenizer
,如文档中所述。另一个相关的问题是:Stanford CoreNLP gives NullPointerException。但是,如果只想标记化而不执行其他操作,则可以执行以下操作:相关问题 更多 >
编程相关推荐