Comparing NLTK with spaCy NER
Using the same text you used in the first exercise of this chapter, you'll now see the results using spaCy's NER annotator. How will they compare?
The article has been pre-loaded as article. To minimize execution times, you'll be asked to specify the keyword argument disable=['tagger', 'parser', 'matcher'] when loading the spaCy model, because you only care about the entity in this exercise.
Deze oefening maakt deel uit van de cursus
Introduction to Natural Language Processing in Python
Oefeninstructies
- Import
spacy. - Load the
'en_core_web_sm'model usingspacy.load(). Specify the additional keyword argumentsdisable=['tagger', 'parser', 'matcher']. - Create a
spacydocument object by passingarticleintonlp(). - Using
entas your iterator variable, iterate over the entities ofdocand print out the labels (ent.label_) and text (ent.text).
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Import spacy
____
# Instantiate the English model: nlp
nlp = ____
# Create a new document: doc
doc = ____
# Print all of the found entities and their labels
for ____ in ____:
print(____, ____)