ComenzarEmpieza gratis

Documents, spans and tokens

Cuando llamas a nlp sobre una cadena, spaCy primero tokeniza el texto y crea un objeto documento. En este ejercicio, vas a aprender más sobre el Doc, así como sobre sus vistas Token y Span.

Este ejercicio forma parte del curso

NLP avanzado con spaCy

Ver curso

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Import the English language class and create the nlp object
from ____ import ____
nlp = ____

# Process the text
doc = ____("I like tree kangaroos and narwhals.")

# Select the first token
first_token = doc[____]

# Print the first token's text
print(first_token.____)
Editar y ejecutar código