Fix build with xapian-core < 1.4.10
[xapian.git] / search-xapian / Xapian / TermGenerator.pm
blob515de84cf4c348e040a7e381f96df3c09619fe88
1 package Search::Xapian::TermGenerator;
3 use 5.006;
4 use strict;
5 use warnings;
7 require DynaLoader;
9 our @ISA = qw(DynaLoader);
11 # Preloaded methods go here.
13 # In a new thread, copy objects of this class to unblessed, undef values.
14 sub CLONE_SKIP { 1 }
16 use overload '=' => sub { $_[0]->clone() },
17 'fallback' => 1;
19 sub clone() {
20 my $self = shift;
21 my $class = ref( $self );
22 my $copy = new2( $self );
23 bless $copy, $class;
24 return $copy;
27 sub new() {
28 my $class = shift;
29 my $tg = new0();
31 bless $tg, $class;
33 return $tg;
38 __END__
40 =head1 NAME
42 Search::Xapian::TermGenerator - Parses a piece of text and generates terms.
44 =head1 DESCRIPTION
46 This module takes a piece of text and parses it to produce words which are
47 then used to generate suitable terms for indexing. The terms generated
48 are suitable for use with L<Search::Xapian::Query> objects produced by the
49 L<Search::Xapian::QueryParser> class.
51 =head1 SYNOPSIS
53 use Search::Xapian;
55 my $doc = new Search::Xapian::Document();
56 my $tg = new Search::Xapian::TermGenerator();
57 $tg->set_stemmer(new Search::Xapian::Stem("english"));
58 $tg->set_document($doc);
59 $tg->index_text("The cat sat on the mat");
61 =head1 METHODS
63 =over 4
65 =item new
67 TermGenerator constructor.
69 =item set_stemmer <stemmer>
71 Set the L<Search::Xapian::Stem> object to be used for generating stemmed terms.
73 =item set_stopper <stopper>
75 Set the L<Search::Xapian::Stopper> object to be used for identifying stopwords.
77 =item set_document <document>
79 Set the L<Search::Xapian::Document> object to index terms into.
81 =item get_document <document>
83 Get the currently set L<Search::Xapian::Document> object.
85 =item index_text <text> [<wdf_inc> [<prefix>]]
87 Indexes the text in string <text>. The optional parameter <wdf_inc> sets the
88 wdf increment (default 1). The optional parameter <prefix> sets the term
89 prefix to use (default is no prefix).
91 =item index_text_without_positions <text> [<wdf_inc> [<prefix>]]
93 Just like index_text, but no positional information is generated. This means
94 that the database will be significantly smaller, but that phrase searching
95 and NEAR won't be supported.
97 =item increase_termpos [<delta>]
99 Increase the termpos used by index_text by <delta> (default 100).
101 This can be used to prevent phrase searches from spanning two
102 unconnected blocks of text (e.g. the title and body text).
104 =item get_termpos
106 Get the current term position.
108 =item set_termpos <termpos>
110 Set the current term position.
112 =item get_description
114 Return a description of this object.
116 =back
118 =head1 REFERENCE
120 https://xapian.org/docs/sourcedoc/html/classXapian_1_1TermGenerator.html
122 =cut