xapian-core  2.0.0
stem.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007-2026 Olly Betts
5  * Copyright (C) 2010 Evgeny Sizikov
6  *
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.
11  *
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.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, see
19  * <https://www.gnu.org/licenses/>.
20  */
21 
22 #include <config.h>
23 
24 #include <xapian/stem.h>
25 
26 #include <xapian/error.h>
27 
28 #include "allsnowballheaders.h"
29 #include "keyword.h"
30 #include "sbl-dispatch.h"
31 
32 #include <string>
33 #include <string_view>
34 
35 using namespace std;
36 
37 namespace Xapian {
38 
39 Stem::Stem(std::string_view language, bool fallback)
40 {
41  int l = keyword2(tab, language.data(), language.size());
42  if (l >= 0) {
43  switch (static_cast<sbl_code>(l)) {
45  }
46  }
47  if (fallback || language.empty())
48  return;
49 
50  string m{"Language code "};
51  m += language;
52  m += " unknown";
54 }
55 
56 string
57 Stem::get_description() const
58 {
59  string desc = "Xapian::Stem(";
60  if (internal) {
61  desc += internal->get_description();
62  desc += ')';
63  } else {
64  desc += "none)";
65  }
66  return desc;
67 }
68 
69 bool
70 StemImplementation::use_proper_noun_heuristic() const
71 {
72  return false;
73 }
74 
75 StemImplementation::~StemImplementation() { }
76 
77 }
Include headers for all Snowball stemmers.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Definition: error.h:229
Hierarchy of classes which Xapian can throw as exceptions.
int keyword2(const unsigned char *p, const char *s, size_t len)
2 byte offset variant.
Definition: keyword.cc:56
Efficient keyword to enum lookup.
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:82
Map string to language code.
static const unsigned char tab[]
Definition: sbl-dispatch.h:64
#define SNOWBALL_DISPATCH
Definition: sbl-dispatch.h:162
sbl_code
Definition: sbl-dispatch.h:25
stemming algorithms
static string language
Definition: stemtest.cc:40