Word-sense disambiguation with spaCy
WSD is a classical problem of deciding in which sense a word is used in a sentence. Determining the sense of the word can be crucial in search engines, machine translation, and question-answering systems. In this exercise, you will practice using POS tagging for word-sense disambiguation.
There are two sentences containing the word jam, with two different senses and you are tasked to identify the POS tags to help you determine the corresponding sense of the word in a given sentence.
The two sentences are available in the texts
list. The en_core_web_sm
model is already loaded and available for your use as nlp
.
Diese Übung ist Teil des Kurses
Natural Language Processing with spaCy
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
texts = ["This device is used to jam the signal.",
"I am stuck in a traffic jam"]
# Create a list of Doc containers in the texts list
documents = [____ for t in texts]
# Print a token's text and POS tag if the word jam is in the token's text
for i, doc in enumerate(documents):
print(f"Sentence {i+1}: ", [(____, ____) for token in doc if "jam" in token.text], "\n")