A very important application scenario in machine learning is automatic classification by machines, and the key to classification is stemming. So we need to use snowball. Let’s talk about the two ways snowball extracts stems.
Two methods:
Method 1:
>>> from nltk import SnowballStemmer
>>> SnowballStemmer.languages # See which languages are supported
('danish', 'dutch', 'english', 'finnish' , 'french', 'german', 'hungarian',
'italian', 'norwegian', 'porter', 'portuguese', 'romanian',
'russian', 'spanish', 'swedish')
>> > stemmer = SnowballStemmer("german") # Choose a language
>>> stemmer.stem(u"Autobahnen") # Stem a word
u'autobahn'
But when you know the language scenario you are using, you can use the following The method is directly called:
Method 2:
>>> ps = nltk.stem.snowball.PortugueseStemmer()
>>> ps.stem('celular')
u'celul'
>>> ps.stem(' celular')
u'celul'