Created
July 24, 2020 17:26
-
-
Save EnkrateiaLucca/c141d90f940babeeaa28c611e16214a1 to your computer and use it in GitHub Desktop.
Stemming
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, LancasterStemmer | |
#Instantiating the Stemmer classes from nltk | |
porter = PorterStemmer() | |
lancaster = LancasterStemmer() | |
# Selecting a Sentence | |
sentence = text[3] | |
# Making a nice print output | |
print("Sentence:") | |
print("'" + sentence + "'") | |
print("{0:20} {1:20}".format("Ported Stemmer", "Lancaster Stemmer")) | |
for word in word_tokenize(sentence): | |
print("{0:20} {1:20}".format(porter.stem(word), lancaster.stem(word))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment