from nltk.stem.porter import PorterStemmer
tokenized_words = ['i', 'am', 'humbled', 'by', 'this', 'traditional', 'meeting']
palavras = ['my', 'name', 'is', 'gabriel', 'identifying', 'running', 'music', 'reading', 'observation']
Stemming irá reduzir a palavra ao seu stem através da identificação e remoção de afixos (por exemplo gerúndio) enquanto mantém o significado raiz da palavra. O Construtor PorterStemmer
da biblioteca NLTK implementa o muito utilizado Porter stemming algorithm.
# Cria o stemmer
porter = PorterStemmer()
# Aplica o stemmer
[porter.stem(word) for word in tokenized_words]
['i', 'am', 'humbl', 'by', 'thi', 'tradit', 'meet']
[porter.stem(word) for word in palavras]
['my', 'name', 'is', 'gabriel', 'identifi', 'run', 'music', 'read', 'observ']