Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#project 5 Stemming

Type 1
from nltk.stem import PorterStemmer
ps = PorterStemmer()
# choose some words to be stemmed
words = ["program", "programs", "programmer", "programming", "programmers"]
for w in words:
print(w, " : ", ps.stem(w))

Type 2
#The Lancaster stemmers are more aggressive and dynamic
compared to the other two stemmers.

from nltk import LancasterStemmer


wd = ['sincerely','electricity','roughly','ringing']
Lanc = LancasterStemmer()
for w in wd:
print(w, " : ", Lanc.stem(w))

Type 3
# Snowball Stemmer can improve the accuracy of text analysis
tasks such as sentiment analysis

from nltk.stem.snowball import SnowballStemmer


snow_stemmer = SnowballStemmer(language='english')
words = ['cared','university','fairly','easily','singing',
'sings','sung','singer','sportingly']
stem_words = []
for w in words:
x = snow_stemmer.stem(w)
stem_words.append(x)
print(stem_words)
#for e1,e2 in zip(words,stem_words):
# print(e1+' ----> '+e2)

You might also like