spaCy vocabulary
Word vectors, or word embeddings, are numerical representations of words that allow computers to perform complex tasks using text data. Word vectors are a part of many spaCy models, however, a few of the models do not have word vectors.
In this exercise, you will practice accessing spaCy
vocabulary information. Some meta information about word vectors are stored in each spaCy
model. You can access this information to learn more about the vocabulary size, word vectors dimensions, etc.
The spaCy
package is already imported for your use. In a spaCy
model's metadata, the number of words is stored as an element with the "vectors" key and the dimension of word vectors is stored as an element with the "width" key.
This exercise is part of the course
Natural Language Processing with spaCy
Exercise instructions
- Load the
en_core_web_md
model. - Print the number of words in the
en_core_web_md
model's vocabulary. - Print the dimensions of word vectors in the
en_core_web_md
model.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Load the en_core_web_md model
md_nlp = ____
# Print the number of words in the model's vocabulary
print("Number of words: ", md_nlp.____["vectors"]["vectors"], "\n")
# Print the dimensions of word vectors in en_core_web_md model
print("Dimension of word vectors: ", md_nlp.____["vectors"]["width"])