Entità nominate in una frase
In questo esercizio identificheremo e classificheremo le etichette delle diverse entità nominate in un testo usando uno dei modelli statistici di spaCy. Verificheremo anche l'attendibilità di queste etichette.
Questo esercizio fa parte del corso
Feature Engineering per NLP in Python
Istruzioni dell'esercizio
- Usa
spacy.load()per caricare il modelloen_core_web_sm. - Crea un'istanza Doc
docusandotextenlp. - Cicla su
doc.entsper stampare tutte le entità nominate e le rispettive etichette.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# 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(____, ____)