CommencerCommencer gratuitement

POS tagging in Lord of the Flies

In this exercise, you will perform part-of-speech tagging on a famous passage from one of the most well-known novels of all time, Lord of the Flies, authored by William Golding.

The passage is available as lotf and has already been printed to the console.

Cet exercice fait partie du cours

Feature Engineering for NLP in Python

Afficher le cours

Instructions

  • Load the en_core_web_sm model.
  • Create a doc object for lotf using nlp().
  • Using the text and pos_ attributes, generate tokens and their corresponding POS tags.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Load the en_core_web_sm model
nlp = spacy.load(____)

# Create a Doc object
doc = ___(___)

# Generate tokens and pos tags
pos = [(token.____, token.____) for token in doc]
print(pos)
Modifier et exécuter le code