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. ○ Search the Web for “spoof newspaper headlines,” to find such gems as: British Left Waffles on Falkland Islands, and Juvenile Court to Try Shooting Defendant. Manually tag these headlines to see whether knowledge of the part-of-speech tags removes the ambiguity.

  2. ○ Working with someone else, take turns picking a word that can be either a noun or a verb (e.g., contest); the opponent has to predict which one is likely to be the most frequent in the Brown Corpus. Check the opponent’s prediction, and tally the score over several turns.

  3. ○ Tokenize and tag the following sentence: They wind back the clock, while we chase after the wind. What different pronunciations and parts-of-speech are involved?

  4. ○ Review the mappings in Table 5-4. Discuss any other examples of mappings you can think of. What type of information do they map from and to?

  5. ○ Using the Python interpreter in interactive mode, experiment with the dictionary examples in this chapter. Create a dictionary d, and add some entries. What happens whether you try to access a non-existent entry, e.g., d['xyz']?

  6. ○ Try deleting an element from a dictionary d, using the syntax del d['abc']. Check that the item was deleted.

  7. ○ Create two dictionaries, d1 and d2, and add some entries to each. Now issue the command d1.update(d2). What did this do? What might it be useful for?

  8. ○ Create a dictionary e, to represent a single lexical entry for some word of your choice. Define keys such as headword, part-of-speech, sense, and example, and ...

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