LoslegenKostenlos starten

Named entities in a sentence

In this exercise, we will identify and classify the labels of various named entities in a body of text using one of spaCy's statistical models. We will also verify the veracity of these labels.

Diese Übung ist Teil des Kurses

<Kurs>Feature Engineering for NLP in Python</Kurs>
Kurs ansehen

Übungsanweisungen

  • Use spacy.load() to load the en_core_web_sm model.
  • Create a Doc instance doc using text and nlp.
  • Loop over doc.ents to print all the named entities and their corresponding labels.

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Load the required model
nlp = ____.____(____)

# Create a Doc instance 
text = 'Sundar Pichai is the CEO of Google. Its headquarters is in Mountain View.'
doc = ____

# Print all named entities and their labels
for ent in ____:
    print(____, ____)
Code bearbeiten und ausführen