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

Exercise

EntityRuler for NER

EntityRuler can be combined with EntityRecognizer of an existing model to boost its accuracy. In this exercise, you will practice combining an EntityRuler component and an existing NER component of the en_core_web_sm model. The model is already loaded as nlp.

When EntityRuler is added before NER component, the entity recognizer will respect the existing entity spans and adjust its predictions based on patterns added to the EntityRuler to improve accuracy of named entity recognition task.

Instructions

100 XP
  • Add an EntityRuler to the nlp before ner component.
  • Define a token entity pattern to classify lower cased new york group as ORG.
  • Add the patterns to the EntityRuler component.
  • Run the model and print the tuple of entities text and type for the Doc container.