Want to extract all sentences containing a set of specified words followed by any adjective, e.g. "very good"
I tagged each word with its part of speech to recognize any adjective. Then, I specified the pattern using a regular expression. Here is the code:
import nltk
import os
import string
import re
s=["This","Movie","is","very","good"];
v=["extremely","very"];
tagged=nltk.pos_tag(s);
grammar= """Chunk: {[v[0]-v[4]]<JJ>}""";
parser=nltk.RegexpParser(grammar);
t=parser.parse(tagged);
But it didn't recognize the pattern I specified, no pair was labeled with "Chunk".