>>> 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 wordu'autobahn'
但是当你知道你使用的语言场景的时候可以使用下面的方法直接调用:
方法二:
>>> ps = nltk.stem.snowball.PortugueseStemmer()>>> ps.stem('celular')u'celul'>>> ps.stem('celular')u'celul'