Skip to content
Advertisement

Python, NLP: How to find all trigrams from text files with adjectives as the middle term

I think the question is self-explanatory but here goes the detailed meaning of the question.

I want to extract all trigrams from text files using the nltk library having adjectives as the middle term.

Example Text – A red ball was with the good boy.

Example of output –

JavaScript

and so on

Advertisement

Answer

This code should do it:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement