Home > Backend Development > Python Tutorial > nltk's snowball extracts stems

nltk's snowball extracts stems

高洛峰
Release: 2016-10-18 10:12:57
Original
4556 people have browsed it

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'


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template