def extract_np(psent):
    for subtree in psent.subtrees():
        if subtree.node == 'NP':
            yield ' '.join(word for word, tag in subtree.leaves())
cp = nltk.RegexpParser(grammar)
NLTK: How do I traverse a noun phrase to return list of strings?