man > Lingua::Stem(3pm)

๐Ÿ“› NAME

Lingua::Stem - Stemming of words

๐Ÿš€ Quick Reference

Use CaseCommandDescription
Stem a list of wordsstem(@words)Returns array ref of stemmed words
Create OO stemmerLingua::Stem->new( -locale => 'en-uk' )Instantiate with optional locale
Set locale$stemmer->set_locale('fr')Change locale for instance
Enable caching (level 2)$stemmer->stem_caching({ -level => 2 })Cache indefinitely for speed
Add exceptions$stemmer->add_exceptions({ 'driven' => 'driven' })Override stemming for specific words
Stem inโ€‘place (faster)stem_in_place(@words)Modifies list directly; ~60% faster than stem
Clear cache$stemmer->clear_stem_cacheEmpty the stemming cache

๐Ÿ“ SYNOPSIS

use Lingua::Stem qw(stem);
my $stemmmed_words_anon_array   = stem(@words);

or for the OO inclined,

use Lingua::Stem;
my $stemmer = Lingua::Stem->new(-locale => 'EN-UK');
$stemmer->stem_caching({ -level => 2 });
my $stemmmed_words_anon_array   = $stemmer->stem(@words);

๐Ÿ“– DESCRIPTION

This routine applies stemming algorithms to its parameters, returning the stemmed words as appropriate to the selected locale.

You can import some or all of the class methods.

use Lingua::Stem qw (stem clear_stem_cache stem_caching
                     add_exceptions delete_exceptions
                     get_exceptions set_locale get_locale
                     :all :locale :exceptions :stem :caching);

๐ŸŒ Supported Locales

If you have the memory and lots of stemming to do, I strongly suggest using cache level 2 and processing lists in 'big chunks' (long lists) for best performance.

โš–๏ธ Comparison with Lingua::Stem::Snowball

It functions fairly similarly to the Lingua::Stem::Snowball suite of stemmers, with the most significant differences being

  1. Lingua::Stem is a 'pure perl' (no compiled XS code is needed) suite. Lingua::Stem::Snowball is XS based (must be compiled).
  2. Lingua::Stem works with Perl 5.6 or later. Lingua::Stem::Snowball works with Perl 5.8 or later.
  3. Lingua::Stem has an 'exceptions' system allowing you to override stemming on a 'case by case' basis. Lingua::Stem::Snowball does not have an 'exceptions' system.
  4. A somewhat different set of supported languages:
LanguageISO codeLingua::StemLingua::Stem::Snowball
Danishdaโœ…โœ…
DutchnlโŒโœ…
Englishenโœ…โœ…
FinnishfiโŒโœ…
Frenchfrโœ…โœ…
Galacianglโœ…โŒ
Germandeโœ…โœ…
Italianitโœ…โœ…
Norwegiannoโœ…โœ…
Portugueseptโœ…โœ…
Russianruโœ…โœ…
SpanishesโŒโœ…
Swedishsvโœ…โœ…
  1. Lingua::Stem is faster for 'stem' (circa 30% faster than Lingua::Stem::Snowball)
  2. Lingua::Stem::Snowball is faster for 'stem_in_place' (circa 30% faster than Lingua::Stem)
  3. Lingua::Stem::Snowball is more consistent with regard to character set issues.
  4. Lingua::Stem::Snowball is under active development. Lingua::Stem is currently fairly static.

Some benchmarks using Lingua::Stem 0.82 and Lingua::Stem::Snowball 0.94 gives an idea of how various options impact performance. The dataset was The Works of Edgar Allen Poe, volumes 1-5 from the Gutenberg Project processed 10 times in a row as single batch of words (processing a long text one word at a time is very inefficient and drops the performance of Lingua::Stem by about 90%: So "Don't Do That" ;) )

The benchmarks were run on a 3.06 Ghz P4 with HT on Fedora Core 5 Linux using Perl 5.8.8.

source: collected_works_poe.txtwords: 454691unique words: 22802
moduleconfigavg secswords/sec
Lingua::Stem 0.82no cache1.922236560
Lingua::Stem 0.82cache level 21.235368292
Lingua::Stem 0.82cachelv2, sip0.798569494
Lingua::Stem::Snowball 0.94stem1.622280276
Lingua::Stem::Snowball 0.94stem_in_place0.627725129

The script for the benchmark is included in the examples/ directory of this distribution as benchmark_stemmers.plx.

๐Ÿ“… CHANGES

๐Ÿ”ง METHODS

๐Ÿ“Œ VERSION

2.30 2020.06.20

๐Ÿ“ NOTES

It started with the 'Text::Stem' module which has been adapted into a more general framework and moved into the more language oriented 'Lingua' namespace and re-organized to support an OOP interface as well as switch core 'En' locale stemmers.

Version 0.40 added a cache for stemmed words. This can provide up to a several fold performance improvement.

Organization is such that extending this module to any number of languages should be direct and simple.

Case flattening is a function of the language, so the 'exceptions' methods have to be used appropriately to the language. For 'En' family stemming, use lower case words, only, for exceptions.

๐Ÿ‘ฅ AUTHORS

Jerilyn Franz <cpan AT jerilyn.info>
Jim Richardson <imr AT maths.au>

๐Ÿ™ CREDITS

Jim Richardson <imr AT maths.au>
Ulrich Pfeifer <pfeifer AT ls6.de>
Aldo Calpini <dada AT perl.it>
xern <xern AT cpan.org>
Ask Solem Hoel <ask AT unixmonks.net>
Dennis Haney <davh AT davh.dk>
Sebastien Darribere-Pleyt <sebastien.darribere AT lefute.com>
Aleksandr Guidrevitch <pillgrim AT mail.ru>

๐Ÿ“š SEE ALSO

๐Ÿ“„ Lingua::Stem::En ๐Ÿ“„ Lingua::Stem::En ๐Ÿ“„ Lingua::Stem::Da ๐Ÿ“„ Lingua::Stem::De ๐Ÿ“„ Lingua::Stem::Gl ๐Ÿ“„ Lingua::Stem::No ๐Ÿ“„ Lingua::Stem::Pt ๐Ÿ“„ Lingua::Stem::Sv ๐Ÿ“„ Lingua::Stem::It ๐Ÿ“„ Lingua::Stem::Fr ๐Ÿ“„ Lingua::Stem::Ru ๐Ÿ“„ Text::German ๐Ÿ“„ Lingua::PT::Stemmer ๐Ÿ“„ Lingua::GL::Stemmer ๐Ÿ“„ Lingua::Stem::Snowball::No ๐Ÿ“„ Lingua::Stem::Snowball::Se ๐Ÿ“„ Lingua::Stem::Snowball::Da ๐Ÿ“„ Lingua::Stem::Snowball::Sv ๐Ÿ“„ Lingua::Stemmer::GL ๐Ÿ“„ Lingua::Stem::Snowball ๐Ÿ“„ http://snowball.tartarus.org

ยฉ๏ธ COPYRIGHT

Copyright 1999-2004

Freerun Technologies, Inc (Freerun), Jim Richardson, University of Sydney <imr AT maths.au> and Jerilyn Franz <cpan AT jerilyn.info>. All rights reserved.

Text::German was written and is copyrighted by Ulrich Pfeifer.

Lingua::Stem::Snowball::Da was written and is copyrighted by Dennis Haney and Ask Solem Hoel.

Lingua::Stem::It was written and is copyrighted by Aldo Calpini.

Lingua::Stem::Snowball::No, Lingua::Stem::Snowball::Se, Lingua::Stem::Snowball::Sv were written and are copyrighted by Ask Solem Hoel.

Lingua::Stemmer::GL and Lingua::PT::Stemmer were written and are copyrighted by Xern.

Lingua::Stem::Fr was written and is copyrighted by Aldo Calpini and Sebastien Darribere-Pley.

Lingua::Stem::Ru was written and is copyrighted by Aleksandr Guidrevitch.

This software may be freely copied and distributed under the same terms and conditions as Perl.

๐Ÿ› BUGS

๐Ÿ› None known.

๐Ÿ”ฎ TODO

Add more languages. Extend regression tests. Add support for the Lingua::Stem::Snowball family of stemmers as an alternative core stemming engine. Extend 'stem_in_place' functionality to nonโ€‘English stemmers.

Lingua::Stem(3pm)
๐Ÿ“› NAME ๐Ÿš€ Quick Reference ๐Ÿ“ SYNOPSIS ๐Ÿ“– DESCRIPTION
๐ŸŒ Supported Locales โš–๏ธ Comparison with Lingua::Stem::Snowball
๐Ÿ“… CHANGES ๐Ÿ”ง METHODS ๐Ÿ“Œ VERSION ๐Ÿ“ NOTES ๐Ÿ‘ฅ AUTHORS ๐Ÿ™ CREDITS ๐Ÿ“š SEE ALSO ยฉ๏ธ COPYRIGHT ๐Ÿ› BUGS ๐Ÿ”ฎ TODO

Generated by phpman v4.9.25-25-g40dbf62 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-15 13:31 @2600:1f28:365:80b0:9828:9619:d52a:51a3
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^