def malt_demo(nx=False):
 dg = DependencyGraph(u'Pierre  NNP     2       NMOD\nVinken  NNP     8       SUB\n,       ,       2       P\n61      CD      5       NMOD\nyears   NNS     6       AMOD\nold     JJ      2       NMOD\n,       ,       2       P\nwill    MD      0       ROOT\njoin    VB      8       VC\nthe     DT      11      NMOD\nboard   NN      9       OBJ\nas      IN      9       VMOD\na       DT      15      NMOD\nnonexecutive    JJ      15      NMOD\ndirector        NN      12      PMOD\nNov.    NNP     9       VMOD\n29      CD      16      NMOD\n.       .       9       VMOD\n')
 tree = dg.tree()
 tree.pprint()
 if nx:
  import networkx
  from matplotlib import pylab
  g = dg.nx_graph()
  g.info()
  pos = networkx.spring_layout(g, dim=1)
  networkx.draw_networkx_nodes(g, pos, node_size=50)
  networkx.draw_networkx_labels(g, pos, dg.nx_labels)
  pylab.xticks([])
  pylab.yticks([])
  pylab.savefig(u'tree.png')
  pylab.show()

def malt_demo ( nx = False ) : dg = DependencyGraph ( u'Pierre  NNP     2       NMOD\nVinken  NNP     8       SUB\n,       ,       2       P\n61      CD      5       NMOD\nyears   NNS     6       AMOD\nold     JJ      2       NMOD\n,       ,       2       P\nwill    MD      0       ROOT\njoin    VB      8       VC\nthe     DT      11      NMOD\nboard   NN      9       OBJ\nas      IN      9       VMOD\na       DT      15      NMOD\nnonexecutive    JJ      15      NMOD\ndirector        NN      12      PMOD\nNov.    NNP     9       VMOD\n29      CD      16      NMOD\n.       .       9       VMOD\n' ) tree = dg . tree ( ) tree . pprint ( ) if nx : import networkx from matplotlib import pylab g = dg . nx_graph ( ) g . info ( ) pos = networkx . spring_layout ( g , dim = 1 ) networkx . draw_networkx_nodes ( g , pos , node_size = 50 ) networkx . draw_networkx_labels ( g , pos , dg . nx_labels ) pylab . xticks ( [ ] ) pylab . yticks ( [ ] ) pylab . savefig ( u'tree.png' ) pylab . show ( )
a demonstration of the result of reading a dependency version of the first sentence of the penn treebank .