xapian-core  1.4.26
termgenerator.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2009,2011,2012,2013,2014,2018,2023 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef XAPIAN_INCLUDED_TERMGENERATOR_H
22 #define XAPIAN_INCLUDED_TERMGENERATOR_H
23 
24 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
25 # error Never use <xapian/termgenerator.h> directly; include <xapian.h> instead.
26 #endif
27 
28 #include <xapian/intrusive_ptr.h>
29 #include <xapian/types.h>
30 #include <xapian/unicode.h>
31 #include <xapian/visibility.h>
32 
33 #include <string>
34 
35 namespace Xapian {
36 
37 class Document;
38 class Stem;
39 class Stopper;
40 class WritableDatabase;
41 
49  public:
51  class Internal;
54 
56  TermGenerator(const TermGenerator & o);
57 
59  TermGenerator & operator=(const TermGenerator & o);
60 
61 #ifdef XAPIAN_MOVE_SEMANTICS
64 
66  TermGenerator & operator=(TermGenerator && o);
67 #endif
68 
70  TermGenerator();
71 
73  ~TermGenerator();
74 
76  void set_stemmer(const Xapian::Stem & stemmer);
77 
86  void set_stopper(const Xapian::Stopper *stop = NULL);
87 
89  void set_document(const Xapian::Document & doc);
90 
92  const Xapian::Document & get_document() const;
93 
95  void set_database(const Xapian::WritableDatabase &db);
96 
98  typedef int flags;
99 
101  enum {
103  FLAG_SPELLING = 128, // Value matches QueryParser flag.
104 
127  FLAG_NGRAMS = 2048, // Value matches QueryParser flag.
128 
136  FLAG_CJK_NGRAM = FLAG_NGRAMS // Value matches QueryParser flag.
137  };
138 
140  typedef enum {
141  STEM_NONE, STEM_SOME, STEM_ALL, STEM_ALL_Z, STEM_SOME_FULL_POS
142  } stem_strategy;
143 
145  typedef enum { STOP_NONE, STOP_ALL, STOP_STEMMED } stop_strategy;
146 
159  flags set_flags(flags toggle, flags mask = flags(0));
160 
179  void set_stemming_strategy(stem_strategy strategy);
180 
199  void set_stopper_strategy(stop_strategy strategy);
200 
216  void set_max_word_length(unsigned max_word_length);
217 
224  void index_text(const Xapian::Utf8Iterator & itor,
225  Xapian::termcount wdf_inc = 1,
226  const std::string & prefix = std::string());
227 
234  void index_text(const std::string & text,
235  Xapian::termcount wdf_inc = 1,
236  const std::string & prefix = std::string()) {
237  index_text(Utf8Iterator(text), wdf_inc, prefix);
238  }
239 
250  void index_text_without_positions(const Xapian::Utf8Iterator & itor,
251  Xapian::termcount wdf_inc = 1,
252  const std::string & prefix = std::string());
253 
264  void index_text_without_positions(const std::string & text,
265  Xapian::termcount wdf_inc = 1,
266  const std::string & prefix = std::string()) {
267  index_text_without_positions(Utf8Iterator(text), wdf_inc, prefix);
268  }
269 
278  void increase_termpos(Xapian::termpos delta = 100);
279 
281  Xapian::termpos get_termpos() const;
282 
287  void set_termpos(Xapian::termpos termpos);
288 
290  std::string get_description() const;
291 };
292 
293 }
294 
295 #endif // XAPIAN_INCLUDED_TERMGENERATOR_H
Unicode and UTF-8 related classes and functions.
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:80
typedefs for Xapian
Class representing a stemming algorithm.
Definition: stem.h:62
Parses a piece of text and generate terms.
Definition: termgenerator.h:48
static Xapian::Stem stemmer
Definition: stemtest.cc:41
#define XAPIAN_VISIBILITY_DEFAULT
Definition: visibility.h:28
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
stop_strategy
Stopper strategies, for use with set_stopper_strategy().
stem_strategy
Stemming strategies, for use with set_stemming_strategy().
This class provides read/write access to a database.
Definition: database.h:789
Define XAPIAN_VISIBILITY_* macros.
void index_text(const std::string &text, Xapian::termcount wdf_inc=1, const std::string &prefix=std::string())
Index some text in a std::string.
int flags
For backward compatibility with Xapian 1.2.
Definition: termgenerator.h:98
An iterator which returns Unicode character values from a UTF-8 encoded string.
Definition: unicode.h:38
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
Definition: types.h:83
Abstract base class for stop-word decision functor.
Definition: queryparser.h:50
A smart pointer that uses intrusive reference counting.
Definition: intrusive_ptr.h:81
A handle representing a document in a Xapian database.
Definition: document.h:61
void index_text_without_positions(const std::string &text, Xapian::termcount wdf_inc=1, const std::string &prefix=std::string())
Index some text in a std::string without positional information.