I have a corpus of English sentences
sentences = [
"Mary had a little lamb.",
"John has a cute black pup.",
"I ate five apples."
]
and a grammar (for the sake of simplicity)
grammar = ('''
NP: {<NNP><VBZ|VBD><DT><JJ>*<NN><.>} # NP
''')
I wish to filter out the sentences which don't conform to the grammar. Is there a built-in NLTK function which can achieve this? In the above example, first two sentences follow the pattern of my grammar, but not the last one.