Created
September 12, 2010 01:52
-
-
Save alexbowe/575759 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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