Dependency parsing finds the relationship among words – how words are related to each other. It helps computers to understand sentences for analysis; for example, "Taj Mahal is one of the most beautiful monuments." We can't understand this sentence just by analyzing words. We need to dig down and understand the word order, sentence structure, and parts of speech:
# Import spacy
import spacy
# Load English model for tokenizer, tagger, parser, and NER
nlp = spacy.load('en')
# Create nlp Object to handle linguistic annotations in a documents.
docs=nlp(sentence)
# Visualize the using render function
displacy.render(docs, style="dep", jupyter= True, options={'distance': 150})
This results in the following output:
In the preceding example, we have imported the display class and called its render() method with a NLP text object, style as 'dep', jupyter as True, and options as a dictionary with a distance key and a value...