SWI-Prolog Natural Language Processing Primitives
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog Natural Language Processing Primitives
        • Double Metaphone -- Phonetic string matching
        • Porter Stem -- Determine stem and related routines
        • library(snowball): The Snowball multi-lingual stemmer library
          • snowball/3
          • snowball_current_algorithm/1
        • library(isub): isub: a string similarity measure

3 library(snowball): The Snowball multi-lingual stemmer library

See also
http://snowball.tartarus.org/

This module encapsulates "The C version of the libstemmer library" from the Snowball project. This library provides stemmers in a variety of languages. The interface to this library is very simple:

  • snowball/3 stems a word with a given algorithm
  • snowball_current_algorithm/1 enumerates the provided algorithms.

Here is an example:

?- snowball(english, walking, S).
S = walk.
[det]snowball(+Algorithm, +Input, -Stem)
Apply the Snowball Algorithm on Input and unify the result (an atom) with Stem.

The implementation maintains a cache of stemmers for each thread that accesses snowball/3, providing high-perfomance and thread-safety without locking.

Algorithm is the (english) name for desired algorithm or an 2 or 3 letter ISO 639 language code.
Input is the word to be stemmed. It is either an atom, string or list of chars/codes. The library accepts Unicode characters. Input must be lowercase. See downcase_atom/2.
Errors
- domain_error(snowball_algorithm, Algorithm)
- type_error(atom, Algorithm)
- type_error(text, Input)
[nondet]snowball_current_algorithm(?Algorithm)
True if Algorithm is the official name of an algorithm suported by snowball/3. The predicate is semidet if Algorithm is given.