Last active
July 7, 2016 16:17
-
-
Save MaryamZi/71aee229c67fed45dba6 to your computer and use it in GitHub Desktop.
Blog - NLP - Stemming Example
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
from nltk.stem import PorterStemmer | |
from nltk.tokenize import word_tokenize | |
ps = PorterStemmer(); | |
test_sentence = " learn learned learning learns" | |
tokenized_words = word_tokenize(test_sentence) | |
stemmed_words = [] | |
for i in tokenized_words: | |
stemmed_words.append(ps.stem(i)) | |
print stemmed_words |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing!
Do you know how to remove the prefix that is returned with each word?
[u'learn', u'learn', u'learn', u'learn']
In the above example, how to remove the
u
in front of each word?