Package nltk :: Package draw :: Module tree
[hide private]
[frames] | no frames]

Module tree

source code

Graphically display a Tree.

Classes [hide private]
  TreeSegmentWidget
A canvas widget that displays a single segment of a hierarchical tree.
  TreeWidget
A canvas widget that displays a single Tree.
  TreeView
Functions [hide private]
 
_tree_to_treeseg(canvas, t, make_node, make_leaf, tree_attribs, node_attribs, leaf_attribs, loc_attribs) source code
 
tree_to_treesegment(canvas, t, make_node=<class 'nltk.draw.TextWidget'>, make_leaf=<class 'nltk.draw.TextWidget'>, **attribs)
Convert a Tree into a TreeSegmentWidget.
source code
None
draw_trees(*trees)
Open a new window containing a graphical diagram of the given trees.
source code
 
demo() source code
Function Details [hide private]

tree_to_treesegment(canvas, t, make_node=<class 'nltk.draw.TextWidget'>, make_leaf=<class 'nltk.draw.TextWidget'>, **attribs)

source code 

Convert a Tree into a TreeSegmentWidget.

Parameters:
  • make_node - A CanvasWidget constructor or a function that creates CanvasWidgets. make_node is used to convert the Tree's nodes into CanvasWidgets. If no constructor is specified, then TextWidget will be used.
  • make_leaf - A CanvasWidget constructor or a function that creates CanvasWidgets. make_leaf is used to convert the Tree's leafs into CanvasWidgets. If no constructor is specified, then TextWidget will be used.
  • attribs - Attributes for the canvas widgets that make up the returned TreeSegmentWidget. Any attribute beginning with 'tree_' will be passed to all TreeSegmentWidgets (with the 'tree_' prefix removed. Any attribute beginning with 'node_' will be passed to all nodes. Any attribute beginning with 'leaf_' will be passed to all leaves. And any attribute beginning with 'loc_' will be passed to all text locations (for Trees).