Computational Linguistics 6, Exercise 2: John hit the ball Code (run with py -X utf8, after the chapter's script): rules["NP"].append(("Name",)) lexicon["Name"] = {"john"} for t in parse("john hit the ball".split()): print(show(t)) print(len(parse("john hit the ball".split()))) Output from the run: [S [NP john] [VP hit [NP the ball]]] 1 One parse. Comparison with the Parse tree article's description (S root; NP John; VP containing V hit and an NP made of D the and N ball): - Same shape: S -> NP VP, with the VP holding the verb and an NP. - Label differences: the article calls the determiner D and I called it Det. - My display hides the lexical categories (V, Det, N, Name) because show() prints only the word at a leaf; the tree records them internally. The article's picture shows them. - My NP for "john" goes through the Name category; the article's tree places the word under NP in its description, and I cannot see the picture to say whether it shows an intermediate category. The article's tree is an image, so this comparison rests on its text description.