xapian-core  1.4.19
termgenerator.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2007,2009,2011,2012,2013,2014,2018 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 
118  FLAG_CJK_NGRAM = 2048 // Value matches QueryParser flag.
119  };
120 
122  typedef enum {
123  STEM_NONE, STEM_SOME, STEM_ALL, STEM_ALL_Z, STEM_SOME_FULL_POS
124  } stem_strategy;
125 
127  typedef enum { STOP_NONE, STOP_ALL, STOP_STEMMED } stop_strategy;
128 
141  flags set_flags(flags toggle, flags mask = flags(0));
142 
161  void set_stemming_strategy(stem_strategy strategy);
162 
181  void set_stopper_strategy(stop_strategy strategy);
182 
198  void set_max_word_length(unsigned max_word_length);
199 
206  void index_text(const Xapian::Utf8Iterator & itor,
207  Xapian::termcount wdf_inc = 1,
208  const std::string & prefix = std::string());
209 
216  void index_text(const std::string & text,
217  Xapian::termcount wdf_inc = 1,
218  const std::string & prefix = std::string()) {
219  index_text(Utf8Iterator(text), wdf_inc, prefix);
220  }
221 
232  void index_text_without_positions(const Xapian::Utf8Iterator & itor,
233  Xapian::termcount wdf_inc = 1,
234  const std::string & prefix = std::string());
235 
246  void index_text_without_positions(const std::string & text,
247  Xapian::termcount wdf_inc = 1,
248  const std::string & prefix = std::string()) {
249  index_text_without_positions(Utf8Iterator(text), wdf_inc, prefix);
250  }
251 
260  void increase_termpos(Xapian::termpos delta = 100);
261 
263  Xapian::termpos get_termpos() const;
264 
269  void set_termpos(Xapian::termpos termpos);
270 
272  std::string get_description() const;
273 };
274 
275 }
276 
277 #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:785
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.