diff -U3 -r xapian-clean/search-xapian/t/index.t xapian-test/search-xapian/t/index.t
old
|
new
|
|
32 | 32 | |
33 | 33 | my $term = 'test'; |
34 | 34 | ok( $term = $stemmer->stem_word( $term ) ); |
| 35 | if ($backend ne "inmemory") { |
| 36 | # inmemory doesn't implement spelling correction support. |
| 37 | $database->add_spelling( $term, 1 ); |
| 38 | } |
35 | 39 | |
36 | 40 | my $docid; |
37 | 41 | for my $num qw( one two three ) { |
… |
… |
|
44 | 48 | $docs{$num}->add_posting( $num, 1 ); |
45 | 49 | |
46 | 50 | $docs{$num}->add_value(0, $num); |
| 51 | |
| 52 | if ($backend ne "inmemory") { |
| 53 | # inmemory doesn't implement spelling correction support. |
| 54 | $database->add_spelling( "x" . $term, 1 ); |
| 55 | $database->add_spelling( $term, 1 ); |
| 56 | $database->remove_spelling( "x" . $term, 1 ); |
| 57 | } |
47 | 58 | ok( $docid = $database->add_document( $docs{$num} ) ); |
48 | 59 | } |
49 | 60 | $database->delete_document( $docid ); |
diff -U3 -r xapian-clean/search-xapian/t/parser.t xapian-test/search-xapian/t/parser.t
old
|
new
|
|
6 | 6 | |
7 | 7 | use Test; |
8 | 8 | use Devel::Peek; |
9 | | BEGIN { plan tests => 53 }; |
| 9 | BEGIN { plan tests => 54 }; |
10 | 10 | use Search::Xapian qw(:standard); |
11 | 11 | ok(1); # If we made it this far, we're ok. |
12 | 12 | |
… |
… |
|
29 | 29 | $qp->set_default_op( OP_AND ); |
30 | 30 | |
31 | 31 | my $query; |
32 | | ok( $query = $qp->parse_query( 'one or two', FLAG_BOOLEAN|FLAG_BOOLEAN_ANY_CASE ) ); |
| 32 | ok( $query = $qp->parse_query( 'one or two', FLAG_BOOLEAN|FLAG_BOOLEAN_ANY_CASE|FLAG_SPELLING_CORRECTION ) ); |
| 33 | ok( not $qp->get_corrected_query_string()); |
33 | 34 | ok( $query->get_description(), "Xapian::Query((one:(pos=1) OR two:(pos=2)))" ); |
34 | 35 | |
35 | 36 | ok( $query = $qp->parse_query( 'one OR (two AND three)' ) ); |
… |
… |
|
130 | 131 | ok( $query->get_description(), "Xapian::Query($res)" ); |
131 | 132 | } |
132 | 133 | |
| 134 | |
| 135 | |
133 | 136 | # Regression test for Search::Xapian bug fixed in 1.0.5.0. In 1.0.0.0-1.0.4.0 |
134 | 137 | # we tried to catch const char * not Xapian::Error, so std::terminate got |
135 | 138 | # called. |
diff -U3 -r xapian-clean/search-xapian/t/search.t xapian-test/search-xapian/t/search.t
old
|
new
|
|
6 | 6 | # change 'tests => 1' to 'tests => last_test_to_print'; |
7 | 7 | |
8 | 8 | use Test::More; |
9 | | BEGIN { plan tests => 114 }; |
| 9 | BEGIN { plan tests => 115 }; |
10 | 10 | use Search::Xapian qw(:ops); |
11 | 11 | |
12 | 12 | ######################### |
… |
… |
|
55 | 55 | |
56 | 56 | ok( $enq = $db->enquire( $query ), "db queries return ok" ); |
57 | 57 | ok( $enq = $db->enquire( OP_OR, 'test', 'help' ), "in-line db queries return ok" ); |
| 58 | is( $db->get_spelling_suggestion( 'tost' ), 'test', "spelling suggestion ok" ); |
58 | 59 | |
59 | 60 | ok( $query = Search::Xapian::Query->new(OP_SCALE_WEIGHT, $query, 3.14), "OP_SCALE_WEIGHT understood" ); |
60 | 61 | |
diff -U3 -r xapian-clean/search-xapian/Xapian/Database.pm xapian-test/search-xapian/Xapian/Database.pm
old
|
new
|
|
138 | 138 | |
139 | 139 | return a description of this object. |
140 | 140 | |
| 141 | =item get_spelling_suggestion |
| 142 | |
| 143 | returns a suggested spelling correction. |
| 144 | |
141 | 145 | =item allterms_begin [<prefix>] |
142 | 146 | |
143 | 147 | Returns a L<Search::Xapian::TermIterator> iterating over the termlist for the |
diff -U3 -r xapian-clean/search-xapian/Xapian/QueryParser.pm xapian-test/search-xapian/Xapian/QueryParser.pm
old
|
new
|
|
157 | 157 | |
158 | 158 | Returns a string describing this object. |
159 | 159 | |
| 160 | =item get_corrected_query_string |
| 161 | |
| 162 | Get the spelling-corrected query string. |
| 163 | |
| 164 | This will only be set if FLAG_SPELLING_CORRECTION is specified when |
| 165 | QueryParser::parse_query() was last called. |
| 166 | |
| 167 | If there were no corrections, an empty string is returned. |
| 168 | |
160 | 169 | =back |
161 | 170 | |
162 | 171 | =head1 REFERENCE |
diff -U3 -r xapian-clean/search-xapian/Xapian/WritableDatabase.pm xapian-test/search-xapian/Xapian/WritableDatabase.pm
old
|
new
|
|
174 | 174 | replaced and an exception is thrown (possibly at a later time when flush is |
175 | 175 | called or the database is closed). |
176 | 176 | |
| 177 | =item add_spelling <word> <freqinc> |
| 178 | |
| 179 | Add a word to the spelling dictionary. |
| 180 | |
| 181 | If the word is already present, its frequency is increased. |
| 182 | |
| 183 | Parameters: |
| 184 | word The word to add. |
| 185 | freqinc How much to increase its frequency by (default 1). |
| 186 | |
| 187 | =item remove_spelling <word> <freqdec> |
| 188 | |
| 189 | Remove a word from the spelling dictionary. |
| 190 | |
| 191 | The word's requency is decreased, and if would become zero or less |
| 192 | then the word is removed completely. |
| 193 | |
| 194 | Parameters: |
| 195 | word The word to remove. |
| 196 | freqdec How much to decrease its frequency by (default 1). |
| 197 | |
177 | 198 | =item reopen |
178 | 199 | |
179 | | Re-open the database. makes sure you have a fresh db handle. |
| 200 | Re-open the database. Makes sure you have a fresh db handle. |
| 201 | |
| 202 | =item close |
| 203 | |
| 204 | Close the database. This also implies a flush(). |
180 | 205 | |
181 | 206 | =back |
182 | 207 | |
diff -U3 -r xapian-clean/search-xapian/XS/Database.xs xapian-test/search-xapian/XS/Database.xs
old
|
new
|
|
256 | 256 | RETVAL |
257 | 257 | |
258 | 258 | string |
| 259 | Database::get_spelling_suggestion(word, max_edit_distance = 2) |
| 260 | string word |
| 261 | int max_edit_distance |
| 262 | CODE: |
| 263 | try { |
| 264 | RETVAL = THIS->get_spelling_suggestion(word, max_edit_distance); |
| 265 | } |
| 266 | catch (const Error &error) { |
| 267 | croak( "Exception: %s", error.get_msg().c_str() ); |
| 268 | } |
| 269 | OUTPUT: |
| 270 | RETVAL |
| 271 | |
| 272 | string |
259 | 273 | Database::get_metadata(string key) |
260 | 274 | |
261 | 275 | void |
diff -U3 -r xapian-clean/search-xapian/XS/QueryParser.xs xapian-test/search-xapian/XS/QueryParser.xs
old
|
new
|
|
99 | 99 | RETVAL |
100 | 100 | |
101 | 101 | string |
| 102 | QueryParser::get_corrected_query_string() |
| 103 | CODE: |
| 104 | try { |
| 105 | RETVAL = THIS->get_corrected_query_string(); |
| 106 | } |
| 107 | catch (const Error &error) { |
| 108 | croak( "Exception: %s", error.get_msg().c_str() ); |
| 109 | } |
| 110 | OUTPUT: |
| 111 | RETVAL |
| 112 | |
| 113 | |
| 114 | string |
102 | 115 | QueryParser::get_description() |
103 | 116 | |
104 | 117 | void |
diff -U3 -r xapian-clean/search-xapian/XS/WritableDatabase.xs xapian-test/search-xapian/XS/WritableDatabase.xs
old
|
new
|
|
417 | 417 | } catch (const Error &error) { |
418 | 418 | croak( "Exception: %s", error.get_msg().c_str() ); |
419 | 419 | } |
| 420 | |
| 421 | void |
| 422 | WritableDatabase::add_spelling(word, freqinc = 1) |
| 423 | string word |
| 424 | termcount freqinc |
| 425 | CODE: |
| 426 | try { |
| 427 | THIS->add_spelling(word, freqinc); |
| 428 | } catch (const Error &error) { |
| 429 | croak( "Exception: %s", error.get_msg().c_str() ); |
| 430 | } |
| 431 | |
| 432 | void |
| 433 | WritableDatabase::remove_spelling(word, freqdec = 1) |
| 434 | string word |
| 435 | termcount freqdec |
| 436 | CODE: |
| 437 | try { |
| 438 | THIS->remove_spelling(word, freqdec); |
| 439 | } catch (const Error &error) { |
| 440 | croak( "Exception: %s", error.get_msg().c_str() ); |
| 441 | } |