Visualizing the relationship

spaCy has a built-in tool called displacy for displaying simple, but clean and powerful visualizations. It offers two primary modes: named entity recognition and dependency parsing. Here, we will use the dep, or dependency mode:

displacy.render(doc, style='dep', jupyter=True)

Let's take the first sentence for a quick study: we can see that instrument is amod, or adjectively modified by Indian classicial. We pulled this phrase earlier as a noun chunk:

This means that when we pulled noun phrase chunks out of this sentence, spaCy must have finished dependency parsing already under the hood.

Also, notice the direction ...

Get Natural Language Processing with Python Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.