Ich möchte die Analyse (POS-Tagging) von openNLP als eine Baumstruktur Visualisierung anzeigen. Im Folgenden stelle ich den Parse-Baum von openNLP, aber ich kann nicht als visueller Baum gemeinsamen Python's parsing plotten.Visualisieren Parse Struktur
install.packages(
"http://datacube.wu.ac.at/src/contrib/openNLPmodels.en_1.5-1.tar.gz",
repos=NULL,
type="source"
)
library(NLP)
library(openNLP)
x <- 'Scroll bar does not work the best either.'
s <- as.String(x)
## Annotators
sent_token_annotator <- Maxent_Sent_Token_Annotator()
word_token_annotator <- Maxent_Word_Token_Annotator()
parse_annotator <- Parse_Annotator()
a2 <- annotate(s, list(sent_token_annotator, word_token_annotator))
p <- parse_annotator(s, a2)
ptext <- sapply(p$features, `[[`, "parse")
ptext
Tree_parse(ptext)
## > ptext
## [1] "(TOP (S (NP (NNP Scroll) (NN bar)) (VP (VBZ does) (RB not) (VP (VB work) (NP (DT the) (JJS best)) (ADVP (RB either))))(. .)))"
## > Tree_parse(ptext)
## (TOP
## (S
## (NP (NNP Scroll) (NN bar))
## (VP (VBZ does) (RB not) (VP (VB work) (NP (DT the) (JJS best)) (ADVP (RB either))))
## (. .)))
Die Baumstruktur sollte wie folgt aussehen:
Gibt es eine Möglichkeit, diesen Baum Visualisierung angezeigt werden?
Ich habe this related tree viz Frage für das Plotten von numerischen Ausdrücken gefunden, die von Nutzen sein können, aber das ich nicht generalisieren konnte, um Parse-Visualisierung zu verallgemeinern.
Okay, wie
Erstellen Sie das Diagramm sieht, aber was danach? – Indi
Vielleicht über https://en.wikibooks.org/wiki/LaTeX/Linguistics#tikz-qtree? – Reactormonk