0
c'est une question idiote, mais comment puis-je imprimer le résultat de l'arbre d'analyse PNL en arborescence?Stanford NLP: imprimer l'arbre d'analyse en arbre format
Ceci est mon code:
public static void main(String[] args) {
Annotation document =
new Annotation("My dog also likes eating sausage.");
Properties props = new Properties();
props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
pipeline.annotate(document);
for (CoreMap sentence : document.get(CoreAnnotations.SentencesAnnotation.class)) {
Tree constituencyParse = sentence.get(TreeCoreAnnotations.TreeAnnotation.class);
System.out.println(constituencyParse);
}
}
lors de l'exécution, je reçois le résultat suivant dans la console Eclipse:
(ROOT (S (NP (PRP$ My) (NN dog)) (ADVP (RB also)) (VP (VBZ likes) (NP (JJ eating) (NN sausage))) (. .)))
Est-il possible d'imprimer ce dans le format d'arbre réel savoir quelque chose comme ça?
(ROOT
(S
(NP (PRP$ My) (NN dog))
(ADVP (RB also))
(VP (VBZ likes)
(S
(VP (VBG eating)
(NP (NN sausage)))))
(. .)))