<jupyter_start><jupyter_text>http://cpmarkchang.logdown.com/posts/184948-python-nltk-tree<jupyter_code># Draw a tree

from nltk import Tree

tree = Tree('S', [Tree('NP', ['Gary']),
                  Tree('VP', [Tree('VT', ['plays']),
                              Tree('NP', ['baseball'])])])
tree.draw()

tree.pprint()
tree.productions()
tree2= Tree('S', [ Tree('NP', ['Gary']),
                     Tree('VT', ['play']), 
                     Tree('NP', ['baeball'])])
tree2.chomsky_normal_form()
tree2.productions()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21350364963503649, 'fraction_numerical': 0.016423357664233577, 'mean_word_length': 2.9214285714285713, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '514527', 'license': 'MIT', 'n_tokens_mistral': 205, 'n_tokens_neox': 195, 'n_words': 30, 'path': 'Packages/nltk/Grammar.ipynb', 'repo_name': 'Lee-W/Python-Note', 'size': '548'}