In Natural Language Processing, stemming is the method to extract the root word by removing suffixes and prefixes from a word.
For example, we can reduce ‘stemming’ to ‘stem’ by removing ‘m’ and ‘ing.’
We use various algorithms for implementing stemming, and one of them is PorterStemmer.
First, we will import PorterStemmer from the nltk package.
from nltk.stem import PorterStemmer
Creating an object for PorterStemmer
pst=PorterStemmer()
pst.stem(“running”), pst.stem(“cookies”), pst.stem(“flying”)
Output:
(‘run’, ‘cooki', ‘fly’ )