2

So drawing a parse tree in nltk is pretty easy. What is not easy is trying to read through the vague docs and lack of examples to figure out how to color vertices in this tree. Surely this is a feature and should be fairly easy to do? Here is an example of a parse tree. I'd like to be able to specify certain nodes to be colored, for example, red. How might I do this?

from nltk.draw.util import *
from nltk.draw.tree import *
tree_string = "(ROOT (S (NP (DT The) (NN cat)) (VP (VBD ate) (NP (DT   the) (NN mouse))) (. .)))"
t = Tree.fromstring(tree_string)
draw_trees(t)
Gaunnett
  • 21
  • 1

0 Answers0