Cover by Edward Loper, Steven Bird, Ewan Klein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Exercises

  1. ○ Can you come up with grammatical sentences that probably have never been uttered before? (Take turns with a partner.) What does this tell you about human language?

  2. ○ Recall Strunk and White’s prohibition against using a sentence-initial however to mean “although.” Do a web search for however used at the start of the sentence. How widely used is this construction?

  3. ○ Consider the sentence Kim arrived or Dana left and everyone cheered. Write down the parenthesized forms to show the relative scope of and and or. Generate tree structures corresponding to both of these interpretations.

  4. ○ The Tree class implements a variety of other useful methods. See the Tree help documentation for more details (i.e., import the Tree class and then type help(Tree)).

  5. ○ In this exercise you will manually construct some parse trees.

    1. Write code to produce two trees, one for each reading of the phrase old men and women.

    2. Encode any of the trees presented in this chapter as a labeled bracketing, and use nltk.Tree() to check that it is well-formed. Now use draw() to display the tree.

    3. As in (a), draw a tree for The woman saw a man last Thursday.

  6. ○ Write a recursive function to traverse a tree and return the depth of the tree, such that a tree with a single node would have depth zero. (Hint: the depth of a subtree is the maximum depth of its children, plus one.)

  7. ○ Analyze the A.A. Milne sentence about Piglet, by underlining all of the sentences it contains then replacing these with S (e.g., the first sentence ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required