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.
Latihan ini adalah bagian dari kursus
Feature Engineering for NLP in Python
Petunjuk latihan
- Use
spacy.load()to load theen_core_web_smmodel. - Create a Doc instance
docusingtextandnlp. - Loop over
doc.entsto print all the named entities and their corresponding labels.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# 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(____, ____)