2 * @brief Implementation of Xapian::Stem API class.
4 /* Copyright (C) 2007,2008,2010,2011,2012,2015,2018,2019,2024 Olly Betts
5 * Copyright (C) 2010 Evgeny Sizikov
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <xapian/stem.h>
26 #include <xapian/error.h>
28 #include "steminternal.h"
30 #include "allsnowballheaders.h"
32 #include "sbl-dispatch.h"
35 #include <string_view>
41 Stem::Stem(std::string_view language
, bool fallback
)
43 int l
= keyword2(tab
, language
.data(), language
.size());
45 switch (static_cast<sbl_code
>(l
)) {
47 internal
= new InternalStemArabic
;
50 internal
= new InternalStemArmenian
;
53 internal
= new InternalStemBasque
;
56 internal
= new InternalStemCatalan
;
59 internal
= new InternalStemDanish
;
62 internal
= new InternalStemDutch
;
65 internal
= new InternalStemEarlyenglish
;
68 internal
= new InternalStemEnglish
;
71 internal
= new InternalStemFinnish
;
74 internal
= new InternalStemFrench
;
77 internal
= new InternalStemGerman
;
80 internal
= new InternalStemGerman2
;
83 internal
= new InternalStemHungarian
;
86 internal
= new InternalStemIndonesian
;
89 internal
= new InternalStemIrish
;
92 internal
= new InternalStemItalian
;
95 internal
= new InternalStemKraaij_pohlmann
;
98 internal
= new InternalStemLithuanian
;
101 internal
= new InternalStemLovins
;
104 internal
= new InternalStemNepali
;
107 internal
= new InternalStemNorwegian
;
112 internal
= new InternalStemPortuguese
;
115 internal
= new InternalStemPorter
;
118 internal
= new InternalStemRussian
;
121 internal
= new InternalStemRomanian
;
124 internal
= new InternalStemSpanish
;
127 internal
= new InternalStemSwedish
;
130 internal
= new InternalStemTamil
;
133 internal
= new InternalStemTurkish
;
137 if (fallback
|| language
.empty())
140 string m
{"Language code "};
143 throw Xapian::InvalidArgumentError(m
);
147 Stem::operator()(const std::string
&word
) const
149 if (!internal
|| word
.empty()) return word
;
150 return internal
->operator()(word
);
154 Stem::get_description() const
156 string desc
= "Xapian::Stem(";
158 desc
+= internal
->get_description();