Exercises

  1. In Example 11-7 the new field appeared at the bottom of the entry. Modify this program so that it inserts the new subelement right after the lx field. (Hint: create the new cv field using Element('cv'), assign a text value to it, then use the insert() method of the parent element.)

  2. Write a function that deletes a specified field from a lexical entry. (We could use this to sanitize our lexical data before giving it to others, e.g., by removing fields containing irrelevant or uncertain content.)

  3. Write a program that scans an HTML dictionary file to find entries having an illegal part-of-speech field, and then reports the headword for each entry.

  4. Write a program to find any parts-of-speech (ps field) that occurred less than 10 times. Perhaps these are typing mistakes?

  5. We saw a method for adding a cv field (Working with Toolbox Data). There is an interesting issue with keeping this up-to-date when someone modifies the content of the lx field on which it is based. Write a version of ...

Get Natural Language Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.