Lingua...owball(3pm)
β¨ NAME β¨
This is user-contributed Perl documentation for Lingua::Stem::Snowball (section 3pm) β Perl interface to Snowball stemmers. Bestie, itβs literally the Perl bindings situation for the Snowball stemmers, and itβs here to help you chop words down to their roots. π
πΈ SYNOPSIS πΈ
my @words = qw( horse hooves );
# OO interface:
my $stemmer = Lingua::Stem::Snowball->new( lang => 'en' );
$stemmer->stem_in_place( \@words ); # qw( hors hoov )
# Functional interface:
my @stems = stem( 'en', \@words );
π¦ DESCRIPTION π¦
Stemming reduces related words to a common root form β for instance, "horse", "horses", and "horsing" all become "hors". Most commonly, stemming is deployed as part of a search application, allowing searches for a given term to match documents which contain other forms of that term. Itβs giving search-engine main character energy, no cap. π₯
This module is very similar to Lingua::Stem β however, Lingua::Stem is pure Perl, while Lingua::Stem::Snowball is an XS module which provides a Perl interface to the C version of the Snowball stemmers. (<http://snowball.tartarus.org>). Slay.
π Supported Languages π
The following stemmers are available (as of Lingua::Stem::Snowball 0.95):
- Danish β ISO code
daβ default encodingISO-8859-1β also available:UTF-8 - Dutch β ISO code
nlβ default encodingISO-8859-1β also available:UTF-8 - English β ISO code
enβ default encodingISO-8859-1β also available:UTF-8 - Finnish β ISO code
fiβ default encodingISO-8859-1β also available:UTF-8 - French β ISO code
frβ default encodingISO-8859-1β also available:UTF-8 - German β ISO code
deβ default encodingISO-8859-1β also available:UTF-8 - Hungarian β ISO code
huβ default encodingISO-8859-1β also available:UTF-8 - Italian β ISO code
itβ default encodingISO-8859-1β also available:UTF-8 - Norwegian β ISO code
noβ default encodingISO-8859-1β also available:UTF-8 - Portuguese β ISO code
ptβ default encodingISO-8859-1β also available:UTF-8 - Romanian β ISO code
roβ default encodingISO-8859-2β also available:UTF-8 - Russian β ISO code
ruβ default encodingKOI8-Rβ also available:UTF-8 - Spanish β ISO code
esβ default encodingISO-8859-1β also available:UTF-8 - Swedish β ISO code
svβ default encodingISO-8859-1β also available:UTF-8 - Turkish β ISO code
trβ default encodingUTF-8β also available: (nothing listed)
π Benchmarks π
Here is a comparison of Lingua::Stem::Snowball and Lingua::Stem, using The Works of Edgar Allen Poe, volumes 1-5 (via Project Gutenberg) as source material. It was produced on a 3.2GHz Pentium 4 running FreeBSD 5.3 and Perl 5.8.7. (The benchmarking script is included in this distribution: devel/benchmark_stemmers.plx.)
- total words:
454285; unique words:22748 Lingua::Stem 0.81β configno cacheβ avg secs2.029β rate223881Lingua::Stem 0.81β configcache level 2β avg secs1.280β rate355025Lingua::Stem::Snowball 0.94β configstemβ avg secs1.426β rate318636Lingua::Stem::Snowball 0.94β configstem_in_placeβ avg secs0.641β rate708495
π METHODS / FUNCTIONS π
π new
my $stemmer = Lingua::Stem::Snowball->new(
lang => 'es',
encoding => 'UTF-8',
);
die $@ if $@;
Create a Lingua::Stem::Snowball object. new() accepts the following hash style parameters:
lang: An ISO code taken from the table of supported languages, above.encoding: A supported character encoding.
β οΈ Be careful with the values you supply tonew(). Iflangis invalid,Lingua::Stem::Snowballdoes not throw an exception, but instead sets$@. Also, if you supply an invalid combination of values forlangandencoding,Lingua::Stem::Snowballwill not warn you, but the behavior will change:stem()will always returnundef, andstem_in_place()will be a no-op. π
βοΈ stem
@stemmed = $stemmer->stem( WORDS, [IS_STEMMED] );
@stemmed = stem( ISO_CODE, WORDS, [LOCALE], [IS_STEMMED] );
Return lowercased and stemmed output. WORDS may be either an array of words or a single scalar word.
In a scalar context, stem() returns the first item in the array of stems:
$stem = $stemmer->stem($word);
$first_stem = $stemmer->stem(\@words); # probably wrong
LOCALE has no effect; it is only there as a placeholder for backwards compatibility (see Changes). IS_STEMMED must be a reference to a scalar; if it is supplied, it will be set to 1 if the output differs from the input in some way, 0 otherwise.
β‘ stem_in_place
$stemmer->stem_in_place(\@words);
This is a high-performance, streamlined version of stem() (in fact, stem() calls stem_in_place() internally). It has no return value, instead modifying each item in an existing array of words. The words must already be in lower case. π
π£οΈ lang
my $lang = $stemmer->lang;
$stemmer->lang($iso_language_code);
Accessor/mutator for the lang parameter. If there is no stemmer for the supplied ISO code, the language is not changed (but $@ is set).
π€ encoding
my $encoding = $stemmer->encoding;
$stemmer->encoding($encoding);
Accessor/mutator for the encoding parameter.
π§ stemmers
my @iso_codes = stemmers();
my @iso_codes = $stemmer->stemmers();
Returns a list of all valid language codes.
π£ REQUESTS & BUGS π£
Please report any requests, suggestions or bugs via the RT bug-tracking system at http://rt.cpan.org/ or email to bug-Lingua-Stem-Snowball@rt.cpan.org.
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Lingua-Stem-Snowball is the RT queue for Lingua::Stem::Snowball. Please check to see if your bug has already been reported. π«Ά
π AUTHORS π
Lingua::Stem::Snowball was originally developed to provide access to stemming algorithms for the OpenFTS (full text search engine) project (<http://openfts.sourceforge.net>), by Oleg Bartunov, <oleg at sai dot msu dot su> and Teodor Sigaev, <teodor at stack dot net>.
Currently maintained by Marvin Humphrey <marvin at rectangular dot com>. Previously maintained by Fabien Potencier <fabpot at cpan dot org>.
π COPYRIGHT AND LICENSE π
Perl bindings copyright 2004-2008 by Marvin Humphrey, Fabien Potencier, Oleg Bartunov and Teodor Sigaev.
This software may be freely copied and distributed under the same terms and conditions as Perl.
Snowball files and stemmers are covered by the BSD license.
π SEE ALSO π
<http://snowball.tartarus.org>, Lingua::Stem.
Okay bestie, thatβs the whole page π. Source/version: perl v5.42.0; date: 2011-11-18. Mwah π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Lingua-Stem-Snowball 0.952-bp160.1.11 Β· GPL-1.0+ or Artistic-1.0
- opensuse-leap 16.0: perl-Lingua-Stem-Snowball 0.952-bp160.1.11 Β· GPL-1.0+ or Artistic-1.0
- opensuse-leap 16.0: perl-Lingua-Stem-Snowball 0.952-bp160.1.11 Β· GPL-1.0+ or Artistic-1.0
- opensuse-leap 16.0: perl-Lingua-Stem-Snowball 0.952-bp160.1.11 Β· GPL-1.0+ or Artistic-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms