Skip to content

Instantly share code, notes, and snippets.

@alexbowe alexbowe/chunks.py
Created Sep 12, 2010

Embed
What would you like to do?
# Extracting nounphrase chunks from a parse tree
# from http://streamhacker.com/2009/02/23/chunk-extraction-with-nltk/
# for each noun phrase sub tree in the parse tree
for subtree in tree.subtrees(filter=lambda t: t.node == 'NP'):
# print the noun phrase as a list of part-of-speech tagged words
print subtree.leaves()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.