Exercise

Entities and extensions

In this exercise, you'll combine custom extension attributes with the model's predictions and create an attribute getter that returns a Wikipedia search URL if the span is a person, organization, or location.

The Span class is already imported and the nlp object has been created for you.

Instructions

100 XP
  • Complete the get_wikipedia_url getter so it only returns the URL if the span's label is in the list of labels.
  • Set the Span extension 'wikipedia_url' using the getter get_wikipedia_url.
  • Iterate over the entities in the doc and output their Wikipedia URL.