2 * @brief Implementation of Xapian::Stem API class.
4 /* Copyright (C) 2007,2008,2010,2011,2012,2015 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"
31 #include "sbl-dispatch.h"
39 Stem::Stem(const Stem
& o
) : internal(o
.internal
) { }
42 Stem::operator=(const Stem
& o
)
44 internal
= o
.internal
;
48 Stem::Stem() : internal(0) { }
50 Stem::Stem(const std::string
&language
) : internal(0) {
51 int l
= keyword(tab
, language
.data(), language
.size());
53 switch (static_cast<sbl_code
>(l
)) {
55 internal
= new InternalStemArmenian
;
58 internal
= new InternalStemBasque
;
61 internal
= new InternalStemCatalan
;
64 internal
= new InternalStemDanish
;
67 internal
= new InternalStemDutch
;
70 internal
= new InternalStemEarlyenglish
;
73 internal
= new InternalStemEnglish
;
76 internal
= new InternalStemFinnish
;
79 internal
= new InternalStemFrench
;
82 internal
= new InternalStemGerman
;
85 internal
= new InternalStemGerman2
;
88 internal
= new InternalStemHungarian
;
91 internal
= new InternalStemItalian
;
94 internal
= new InternalStemKraaij_pohlmann
;
97 internal
= new InternalStemLovins
;
100 internal
= new InternalStemNorwegian
;
105 internal
= new InternalStemPortuguese
;
108 internal
= new InternalStemPorter
;
111 internal
= new InternalStemRussian
;
114 internal
= new InternalStemRomanian
;
117 internal
= new InternalStemSpanish
;
120 internal
= new InternalStemSwedish
;
123 internal
= new InternalStemTurkish
;
127 if (language
.empty())
129 throw Xapian::InvalidArgumentError("Language code " + language
+ " unknown");
132 Stem::Stem(StemImplementation
* p
) : internal(p
) { }
137 Stem::operator()(const std::string
&word
) const
139 if (!internal
.get() || word
.empty()) return word
;
140 return internal
->operator()(word
);
144 Stem::get_description() const
146 string desc
= "Xapian::Stem(";
147 if (internal
.get()) {
148 desc
+= internal
->get_description();