POS tagging with spaCy
In this exercise, you will practice POS tagging. POS tagging is a useful tool in NLP as it allows algorithms to understand the grammatical structure of a sentence and to confirm words that have multiple meanings such as watch and play.
For this exercise, en_core_web_sm has been loaded for you as nlp. Three comments from the Airline Travel Information System (ATIS) dataset have been provided for you in a list called texts.
Diese Übung ist Teil des Kurses
Natural Language Processing with spaCy
Anleitung zur Übung
- Compile
documents, a list of alldoccontainers for each text intextslist using list comprehension. - For each
doccontainer, print each token's text and its corresponding POS tag by iterating throughdocumentsand tokens of eachdoccontainer using a nested for loop.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Compile a list of all Doc containers of texts
documents = [____(text) for text in texts]
# Print token texts and POS tags for each Doc container
for doc in documents:
for ____ in doc:
print("Text: ", ____, "| POS tag: ", ____)
print("\n")