Created
June 17, 2013 03:00
-
-
Save yamaguchiyuto/5794394 to your computer and use it in GitHub Desktop.
Extracting nouns from specified text using python and nltk.
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
import nltk | |
text_str = "I have written this book and these papers." | |
text = nltk.word_tokenize(text_str) | |
result = nltk.pos_tag(text) | |
nouns = [r[0] for r in result if r[1] == 'NN' or r[1] == 'NNS'] | |
print nouns |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment