Ich habe einen Satz John sah einen auffälligen Hut im Laden
Wie stellt man dies als Abhängigkeitsbaum wie unten dargestellt?Dependency Parsing Baum in Spacy
(S
(NP (NNP John))
(VP
(VBD saw)
(NP (DT a) (JJ flashy) (NN hat))
(PP (IN at) (NP (DT the) (NN store)))))
habe ich dieses Skript von here
import spacy
from nltk import Tree
en_nlp = spacy.load('en')
doc = en_nlp("John saw a flashy hat at the store")
def to_nltk_tree(node):
if node.n_lefts + node.n_rights > 0:
return Tree(node.orth_, [to_nltk_tree(child) for child in node.children])
else:
return node.orth_
[to_nltk_tree(sent.root).pretty_print() for sent in doc.sents]
mir die folgenden bekommen, aber ich bin auf der Suche nach einem Baum (NLTK) Format.
saw
____|_______________
| | at
| | |
| hat store
| ___|____ |
John a flashy the