Skip to content

Instantly share code, notes, and snippets.

@yamaguchiyuto
Created June 17, 2013 03:00
Show Gist options
  • Save yamaguchiyuto/5794394 to your computer and use it in GitHub Desktop.
Save yamaguchiyuto/5794394 to your computer and use it in GitHub Desktop.
Extracting nouns from specified text using python and nltk.
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