# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Documents, spans and tokens

# ## Step 1 - Tokens

from spacy.lang.en import English

# Import the English language class and create the nlp object
nlp = English()

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

#Select the first token
first_token = doc[0]

#Print the first token's text
print(first_token.text)

# ## Step 2 - Spans

#A slice of the Doc for tree kangaroos
tree_kangaroos = doc[2:4]

print(tree_kangaroos.text)

#A slice of the Doc for "tree kangaroos and narwhals" without the '.'
tree_kangaroos_and_narwhals = doc[2:6]

print(tree_kangaroos_and_narwhals.text)

StarcoderdataJupyterScriptsDedupFiltered