xapian-core  2.0.0
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Xapian::Stem Class Reference

Class representing a stemming algorithm. More...

#include <stem.h>

+ Collaboration diagram for Xapian::Stem:

Public Member Functions

 Stem (const Stem &o)
 Copy constructor. More...
 
Stemoperator= (const Stem &o)
 Assignment. More...
 
 Stem (Stem &&)=default
 Move constructor. More...
 
Stemoperator= (Stem &&)=default
 Move assignment operator. More...
 
 Stem ()
 Construct a Xapian::Stem object which doesn't change terms. More...
 
 Stem (std::string_view language, bool fallback=false)
 Construct a Xapian::Stem object for a particular language. More...
 
 Stem (StemImplementation *p)
 Construct a Xapian::Stem object with a user-provided stemming algorithm. More...
 
 ~Stem ()
 Destructor. More...
 
std::string operator() (const std::string &word) const
 Stem a word. More...
 
bool is_none () const
 Return true if this is a no-op stemmer. More...
 
std::string get_description () const
 Return a string describing this object. More...
 

Static Public Member Functions

static std::string get_available_languages ()
 Return a list of available languages. More...
 

Private Attributes

Xapian::Internal::intrusive_ptr< StemImplementationinternal
 

Detailed Description

Class representing a stemming algorithm.

Definition at line 74 of file stem.h.

Constructor & Destructor Documentation

◆ Stem() [1/5]

Xapian::Stem::Stem ( const Stem o)
inline

Copy constructor.

Definition at line 80 of file stem.h.

◆ Stem() [2/5]

Xapian::Stem::Stem ( Stem &&  )
default

Move constructor.

◆ Stem() [3/5]

Xapian::Stem::Stem ( )
inline

Construct a Xapian::Stem object which doesn't change terms.

Equivalent to Stem("none").

Definition at line 98 of file stem.h.

◆ Stem() [4/5]

Xapian::Stem::Stem ( std::string_view  language,
bool  fallback = false 
)

Construct a Xapian::Stem object for a particular language.

Parameters
languageEither the English name for the language or the two letter ISO639 code.

The following language names are understood (aliases follow the name):

  • none - don't stem terms
  • arabic (ar) - Since Xapian 1.3.5
  • armenian (hy) - Since Xapian 1.3.0
  • basque (eu) - Since Xapian 1.3.0
  • catalan (ca) - Since Xapian 1.3.0
  • danish (da)
  • dutch (nl, kraaij_pohlmann) - Before Xapian 2.0.0, "dutch" was Martin Porter's Dutch stemmer, and a stemmer which approximately implemented the Kraaij-Pohlmann Dutch stemmer was available separately as "kraaij_pohlmann".
  • dutch_porter - This was the "dutch" stemmer before Xapian 2.0.0. In 1.4.x for x >= 28, "dutch_porter" was an alias for dutch to provide forward compatibility to Xapian 2.
  • english (en) - Martin Porter's 2002 revision of his stemmer
  • earlyenglish - English stemmer with additional rules to improve handling of Early Modern English (e.g. Shakespeare, Dickens) but these overstem some words in contemporary English (since Xapian 1.3.2; originally this was based on "porter", since Xapian 2.0.0 this is based on "english").
  • lovins - Lovin's English stemmer
  • porter - Porter's English stemmer exactly matching his 1980 paper
  • esperanto (eo) - Since Xapian 2.0.0
  • estonian (et) - Since Xapian 2.0.0
  • finnish (fi)
  • french (fr)
  • german (de, german2) - Before Xapian 2.0.0, german2 was a separate variant of the german stemmer which normalised umlauts (e.g. รค and ae). The two variants have now been merged into one.
  • greek (el) - Since Xapian 2.0.0
  • hindi (hi) - Since Xapian 2.0.0
  • hungarian (hu)
  • indonesian (id) - Since Xapian 1.4.6
  • irish (ga) - Since Xapian 1.4.7
  • italian (it)
  • lithuanian (lt) - Since Xapian 1.4.7
  • nepali (ne) - Since Xapian 1.4.7
  • norwegian (nb, nn, no)
  • polish (pl) - Since Xapian 2.0.0
  • portuguese (pt)
  • romanian (ro)
  • russian (ru)
  • serbian (sr) - Since Xapian 2.0.0
  • spanish (es)
  • swedish (sv)
  • tamil (ta) - Since Xapian 1.4.7
  • turkish (tr)
  • yiddish (yi) - Since Xapian 2.0.0
Parameters
fallbackIf true then treat unknown language as "none", otherwise an exception is thrown (default: false). Parameter added in Xapian 1.4.14 - older versions always threw an exception.
Exceptions
Xapian::InvalidArgumentErroris thrown if language isn't recognised and fallback is false.

Definition at line 39 of file stem.cc.

References keyword2(), language, SNOWBALL_DISPATCH, and tab.

◆ Stem() [5/5]

Xapian::Stem::Stem ( StemImplementation p)
inlineexplicit

Construct a Xapian::Stem object with a user-provided stemming algorithm.

You can subclass Xapian::StemImplementation to implement your own stemming algorithm (or to wrap a third-party algorithm) and then wrap your implementation in a Xapian::Stem object to pass to the Xapian API.

Parameters
pThe user-subclassed StemImplementation object. This is reference counted, and so will be automatically deleted by the Xapian::Stem wrapper when no longer required.

Definition at line 177 of file stem.h.

◆ ~Stem()

Xapian::Stem::~Stem ( )
inline

Destructor.

Definition at line 180 of file stem.h.

Member Function Documentation

◆ get_available_languages()

static std::string Xapian::Stem::get_available_languages ( )
inlinestatic

Return a list of available languages.

Each stemmer is only included once in the list (not once for each alias). The name included is the English name of the language.

The list is returned as a string, with language names separated by spaces. This is a static method, so a Xapian::Stem object is not required for this operation.

Definition at line 208 of file stem.h.

References Xapian::Internal::get_constinfo_(), Xapian::Internal::constinfo::stemmer_data, and Xapian::Internal::constinfo::stemmer_name_len.

Referenced by DEFINE_TESTCASE(), main(), and print_stemmers().

◆ get_description()

string Xapian::Stem::get_description ( ) const

Return a string describing this object.

Definition at line 57 of file stem.cc.

Referenced by DEFINE_TESTCASE().

◆ is_none()

bool Xapian::Stem::is_none ( ) const
inline

Return true if this is a no-op stemmer.

Definition at line 193 of file stem.h.

Referenced by DEFINE_TESTCASE(), Xapian::TermGenerator::Internal::index_text(), Xapian::QueryParser::Internal::parse_query(), and State::State().

◆ operator()()

std::string Xapian::Stem::operator() ( const std::string &  word) const
inline

Stem a word.

Parameters
worda word to stem.
Returns
the stem

Definition at line 187 of file stem.h.

◆ operator=() [1/2]

Stem& Xapian::Stem::operator= ( const Stem o)
inline

Assignment.

Definition at line 83 of file stem.h.

References internal.

◆ operator=() [2/2]

Stem& Xapian::Stem::operator= ( Stem &&  )
default

Move assignment operator.

Member Data Documentation

◆ internal

Xapian::Internal::intrusive_ptr<StemImplementation> Xapian::Stem::internal
private

Reference counted internals.

Definition at line 77 of file stem.h.

Referenced by operator=(), and State::State().


The documentation for this class was generated from the following files: