Stanford nlp 如何从CoreNLP服务器';python中返回的字符串是什么?

Stanford nlp 如何从CoreNLP服务器';python中返回的字符串是什么?,stanford-nlp,corenlp-server,Stanford Nlp,Corenlp Server,我正在corenlp服务器上使用pycorenlp。我可以得到字符串格式的解析树。但是我能像NLTK图书馆一样把它当作一棵树吗 from pycorenlp import StanfordCoreNLP import pprint import nltk nlp = StanfordCoreNLP('http://localhost:9000') text = ('Purgrug Vobter and Juklog Qligjar vruled into the Battlefield. V

我正在corenlp服务器上使用pycorenlp。我可以得到字符串格式的解析树。但是我能像NLTK图书馆一样把它当作一棵树吗

from pycorenlp import StanfordCoreNLP
import pprint
import nltk

nlp = StanfordCoreNLP('http://localhost:9000')

text = ('Purgrug Vobter and Juklog Qligjar vruled into the Battlefield. Vobter was about to Hellfire. Juklog Qligjar started kiblaring.')

output = nlp.annotate(text, properties={
'annotators': 'tokenize,ssplit,pos,depparse,parse',
'outputFormat': 'json'
})


print [s['parse'] for s in output['sentences']]
输出:

[u'(ROOT\r\n  (S\r\n    (NP (NNP Purgrug) (NNP Vobter)\r\n      (CC and)\r\n      (NNP Juklog) (NNP Qligjar))\r\n    (VP (VBD vruled)\r\n      (PP (IN into)\r\n        (NP (DT the) (NN Battlefield))))\r\n    (. .)))', u'(ROOT\r\n  (S\r\n    (NP (NNP Vobter))\r\n    (VP (VBD was)\r\n      (ADJP (IN about)\r\n        (PP (TO to)\r\n          (NP (NNP Hellfire)))))\r\n    (. .)))', u'(ROOT\r\n  (S\r\n    (NP (NNP Juklog) (NNP Qligjar))\r\n    (VP (VBD started)\r\n      (S\r\n        (VP (VBG kiblaring))))\r\n    (. .)))']

从nltk导入树:

from nltk.tree import *
下一步,为

a = [u'(ROOT\r\n  (S\r\n    (NP (NNP Purgrug) (NNP Vobter)\r\n      (CC and)\r\n      (NNP Juklog) (NNP Qligjar))\r\n    (VP (VBD vruled)\r\n      (PP (IN into)\r\n        (NP (DT the) (NN Battlefield))))\r\n    (. .)))', u'(ROOT\r\n  (S\r\n    (NP (NNP Vobter))\r\n    (VP (VBD was)\r\n      (ADJP (IN about)\r\n        (PP (TO to)\r\n          (NP (NNP Hellfire)))))\r\n    (. .)))', u'(ROOT\r\n  (S\r\n    (NP (NNP Juklog) (NNP Qligjar))\r\n    (VP (VBD started)\r\n      (S\r\n        (VP (VBG kiblaring))))\r\n    (. .)))']

Tree.fromstring(a[0]).pretty_print()
就这些