Drawing parse treesΒΆ

The code in print_penn_trees.py shows you how to print parse trees from a Penn treebank file:

import nltk

nltk_reader = nltk.corpus.reader.BracketParseCorpusReader(\
                                       corpus_directory,\
                                       [parse_file])

tree_list = list(nltk_reader.parsed_sents(parse_file))
for ind in sentences:
         tree_list[ind].draw()

Previous topic

Parser writing help

Next topic

Drawing parse trees

This Page