Part-of-speech tagging

Sometimes, we want to pull out keywords or keyphrases from a larger body of text quickly. This helps us mentally paint a picture of what this text is about. This is particularly helpful in the analysis of texts, like long emails or essays.

As a quick hack, we can pull out all relevant nouns. This is because most keywords are in fact nouns of some form:

example_text = 'Bansoori is an Indian classical instrument. Tom plays Bansoori and Guitar.'
doc = nlp(example_text)

We need noun chunks. Noun chunks are noun phrases not single words, but a short phrase which describes the noun. For example, the blue skies or the world's largest conglomerate.

To get the noun chunks from a document, simply iterate ...

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.