1. Learn
  2. /
  3. Courses
  4. /
  5. Natural Language Processing with spaCy

Connected

Exercise

Compatible training data

Recall that you cannot feed the raw text directly to spaCy. Instead, you need to create an Example object for each training example. In this exercise, you will practice converting a training_data with a single annotated sentence into a list of Example objects.

en_core_web_sm model is already imported and ready for use as nlp. The Example class is also imported for your use.

Instructions

100 XP
  • Iterate through the text and annotations in the training_data, convert the text to a Doc container and store it at doc.
  • Create an Example object using the doc object and the annotations of each training data point, and store it at example_sentence.
  • Append example_sentence to a list of all_examples.