nltk
Stemming
Ricerca…
introduzione
Staminare è una sorta di metodo di normalizzazione. Molte varianti di parole hanno lo stesso significato, se non quando è coinvolto il tempo. Il motivo per cui deriviamo è di accorciare la ricerca e normalizzare le frasi. Fondamentalmente, sta trovando la radice delle parole dopo aver rimosso la parte verbale e tesa da essa. Uno degli algoritmi di derivazione più popolari è lo stelo di Porter, che esiste dal 1979.
Stufato di Porter
Importa
PorterStemmer
e inizializzafrom nltk.stem import PorterStemmer from nltk.tokenize import word_tokenize ps = PorterStemmer()
Traccia una lista di parole
example_words = ["python","pythoner","pythoning","pythoned","pythonly"] for w in example_words: print(ps.stem(w))
Risultato:
python python python python pythonli
Stendi una frase dopo averlo reso simbolico.
new_text = "It is important to by very pythonly while you are pythoning with python. All pythoners have pythoned poorly at least once." word_tokens = word_tokenize(new_text) for w in word_tokens: print(ps.stem(w)) # Passing word tokens into stem method of Porter Stemmer
Risultato:
It is import to by veri pythonli while you are python with python . all python have python poorli at least onc .
Modified text is an extract of the original Stack Overflow Documentation
Autorizzato sotto CC BY-SA 3.0
Non affiliato con Stack Overflow