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

Connected

Exercise

EntityRuler with multi-patterns in spaCy

EntityRuler lets you to add entities to doc.ents and boost its named entity recognition performance. In this exercise, you will practice adding an EntityRuler component to an existing nlp pipeline to ensure multiple entities are correctly being classified.

The en_core_web_sm model is already loaded and is available for your use as nlp. You can access an example text in example_text and use nlp and doc to access an spaCy model and Doc container of example_text respectively.

Instructions

100 XP
  • Print a list of tuples of entities text and types in the example_text with the nlp model.
  • Define multiple patterns to match lower cased brother and sisters to PERSON label.
  • Add an EntityRuler component to the nlp pipeline and add the patterns to the EntityRuler.
  • Print a tuple of text and type of entities for the example_text with the nlp model.