Visualizing the dependency parse
In this recipe, we will learn how to use the displaCy library and visualize the dependency parse. Details about how to create a dependency parse can be found in Chapter 2, Getting the Dependency Parse. We will create two visualizations, one for a short text and another for a long, multi-sentence text.
Getting ready
The displaCy library is part of the spacy package. You need at least version 2.0.12 of the spacy package. If you don't have spacy, install it using the following command:
pip install spacy
To check the version you have, use the following commands:
>>> import spacy >>> print(spacy.__version__) 2.3.0 >>> exit()
If your version is lower than 2.0.12, use the following command to upgrade spacy:
pip install -U spacy
To validate that the models you have on your computer are compatible with your new version of spacy, use the following command:
python -m spacy validate