Skip to content

Instantly share code, notes, and snippets.



Last active Nov 1, 2017
What would you like to do?
An example of NLTK's POS tagging. Output here:
import nltk
from nltk.tokenize import word_tokenize, sent_tokenize
text1 = "I'm going to watch a play tonight."
text2 = "I like to play guitar."
words1 = word_tokenize(text1)
pos_tags1 = nltk.pos_tag(words1)
words2 = word_tokenize(text2)
pos_tags2 = nltk.pos_tag(words2)
print (pos_tags1)
print (pos_tags2)
[('I', 'PRP'), ("'m", 'VBP'), ('going', 'VBG'), ('to', 'TO'), ('watch', 'VB'), ('a', 'DT'), ('play', 'NN'), ('tonight', 'NN'), ('.', '.')]
[('I', 'PRP'), ('like', 'VBP'), ('to', 'TO'), ('play', 'VB'), ('guitar', 'NN'), ('.', '.')]
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.