r52778 - in /branches/upstream/libsearch-xapian-perl/current: Changes META.yml README XS/Database.xs XS/QueryParser.xs XS/WritableDatabase.xs Xapian.pm Xapian/Database.pm Xapian/QueryParser.pm Xapian/WritableDatabase.pm t/index.t t/parser.t t/search.t

olly at users.alioth.debian.org olly at users.alioth.debian.org
Mon Feb 15 08:36:45 UTC 2010


Author: olly
Date: Mon Feb 15 08:36:25 2010
New Revision: 52778

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=52778
Log:
[svn-upgrade] Integrating new upstream version, libsearch-xapian-perl (1.0.18.0)

Modified:
    branches/upstream/libsearch-xapian-perl/current/Changes
    branches/upstream/libsearch-xapian-perl/current/META.yml
    branches/upstream/libsearch-xapian-perl/current/README
    branches/upstream/libsearch-xapian-perl/current/XS/Database.xs
    branches/upstream/libsearch-xapian-perl/current/XS/QueryParser.xs
    branches/upstream/libsearch-xapian-perl/current/XS/WritableDatabase.xs
    branches/upstream/libsearch-xapian-perl/current/Xapian.pm
    branches/upstream/libsearch-xapian-perl/current/Xapian/Database.pm
    branches/upstream/libsearch-xapian-perl/current/Xapian/QueryParser.pm
    branches/upstream/libsearch-xapian-perl/current/Xapian/WritableDatabase.pm
    branches/upstream/libsearch-xapian-perl/current/t/index.t
    branches/upstream/libsearch-xapian-perl/current/t/parser.t
    branches/upstream/libsearch-xapian-perl/current/t/search.t

Modified: branches/upstream/libsearch-xapian-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/Changes?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/Changes (original)
+++ branches/upstream/libsearch-xapian-perl/current/Changes Mon Feb 15 08:36:25 2010
@@ -1,4 +1,8 @@
 Revision history for Perl extension Search::Xapian.
+
+1.0.18.0  Sun Feb 14 10:22:53 UTC 2010
+	[Changes contributed by Henry Combrinck]
+	- Add wrappers for the spelling correction functionality (ticket#420).
 
 1.0.17.0  Wed Nov 18 02:02:41 UTC 2009
 	[Changes contributed by Olly Betts]

Modified: branches/upstream/libsearch-xapian-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/META.yml?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/META.yml (original)
+++ branches/upstream/libsearch-xapian-perl/current/META.yml Mon Feb 15 08:36:25 2010
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                Search-Xapian
-version:             1.0.17.0
+version:             1.0.18.0
 abstract:            Perl XS frontend to the Xapian C++ search library.
 license:             ~
 author:              

Modified: branches/upstream/libsearch-xapian-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/README?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/README (original)
+++ branches/upstream/libsearch-xapian-perl/current/README Mon Feb 15 08:36:25 2010
@@ -1,4 +1,4 @@
-Search::Xapian version 1.0.17.0
+Search::Xapian version 1.0.18.0
 ===============================
 
 This is Search::Xapian, a Perl XS frontend to the Xapian C++ search library.
@@ -42,7 +42,7 @@
 CPAN bug tracker or mail any of the authors individually.
 
 Copyright (c) 2002,2003 Alex Bowley. All rights reserved.
-Copyright (c) 2003,2004,2005,2006,2007,2008,2009 Olly Betts. All rights reserved.
+Copyright (c) 2003,2004,2005,2006,2007,2008,2009,2010 Olly Betts. All rights reserved.
 
 This program is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.

Modified: branches/upstream/libsearch-xapian-perl/current/XS/Database.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/XS/Database.xs?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/XS/Database.xs (original)
+++ branches/upstream/libsearch-xapian-perl/current/XS/Database.xs Mon Feb 15 08:36:25 2010
@@ -278,6 +278,19 @@
         RETVAL
 
 string
+Database::get_spelling_suggestion(word, max_edit_distance = 2)
+    string  word
+    int     max_edit_distance
+    CODE:
+	try {
+	    RETVAL = THIS->get_spelling_suggestion(word, max_edit_distance);
+	} catch (const Error &error) {
+	    croak( "Exception: %s", error.get_msg().c_str() );
+	}
+    OUTPUT:
+	RETVAL
+
+string
 Database::get_metadata(string key)
     CODE:
 	try {

Modified: branches/upstream/libsearch-xapian-perl/current/XS/QueryParser.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/XS/QueryParser.xs?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/XS/QueryParser.xs (original)
+++ branches/upstream/libsearch-xapian-perl/current/XS/QueryParser.xs Mon Feb 15 08:36:25 2010
@@ -99,6 +99,17 @@
 	RETVAL
 
 string
+QueryParser::get_corrected_query_string()
+    CODE:
+    try {
+	RETVAL = THIS->get_corrected_query_string();
+    } catch (const Error &error) {
+	croak( "Exception: %s", error.get_msg().c_str() );
+    }
+    OUTPUT:
+	RETVAL
+
+string
 QueryParser::get_description()
 
 void

Modified: branches/upstream/libsearch-xapian-perl/current/XS/WritableDatabase.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/XS/WritableDatabase.xs?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/XS/WritableDatabase.xs (original)
+++ branches/upstream/libsearch-xapian-perl/current/XS/WritableDatabase.xs Mon Feb 15 08:36:25 2010
@@ -417,3 +417,25 @@
 	} catch (const Error &error) {
 	    croak( "Exception: %s", error.get_msg().c_str() );
 	}
+
+void
+WritableDatabase::add_spelling(word, freqinc = 1)
+    string word
+    termcount freqinc
+    CODE:
+	try {
+	    THIS->add_spelling(word, freqinc);
+	} catch (const Error &error) {
+	    croak( "Exception: %s", error.get_msg().c_str() );
+	}
+
+void
+WritableDatabase::remove_spelling(word, freqdec  = 1)
+    string word
+    termcount freqdec
+    CODE:
+	try {
+	    THIS->remove_spelling(word, freqdec);
+	} catch (const Error &error) {
+	    croak( "Exception: %s", error.get_msg().c_str() );
+	}

Modified: branches/upstream/libsearch-xapian-perl/current/Xapian.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/Xapian.pm?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/Xapian.pm (original)
+++ branches/upstream/libsearch-xapian-perl/current/Xapian.pm Mon Feb 15 08:36:25 2010
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '1.0.17.0';
+our $VERSION = '1.0.18.0';
 
 use Exporter 'import';
 

Modified: branches/upstream/libsearch-xapian-perl/current/Xapian/Database.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/Xapian/Database.pm?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/Xapian/Database.pm (original)
+++ branches/upstream/libsearch-xapian-perl/current/Xapian/Database.pm Mon Feb 15 08:36:25 2010
@@ -138,6 +138,10 @@
 
 return a description of this object.
 
+=item get_spelling_suggestion
+
+returns a suggested spelling correction.
+
 =item allterms_begin [<prefix>]
 
 Returns a L<Search::Xapian::TermIterator> iterating over the termlist for the

Modified: branches/upstream/libsearch-xapian-perl/current/Xapian/QueryParser.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/Xapian/QueryParser.pm?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/Xapian/QueryParser.pm (original)
+++ branches/upstream/libsearch-xapian-perl/current/Xapian/QueryParser.pm Mon Feb 15 08:36:25 2010
@@ -157,6 +157,15 @@
 
 Returns a string describing this object.
 
+=item get_corrected_query_string
+
+Get the spelling-corrected query string.
+
+This will only be set if FLAG_SPELLING_CORRECTION is specified when
+QueryParser::parse_query() was last called.
+
+If there were no corrections, an empty string is returned.
+
 =back
 
 =head1 REFERENCE

Modified: branches/upstream/libsearch-xapian-perl/current/Xapian/WritableDatabase.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/Xapian/WritableDatabase.pm?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/Xapian/WritableDatabase.pm (original)
+++ branches/upstream/libsearch-xapian-perl/current/Xapian/WritableDatabase.pm Mon Feb 15 08:36:25 2010
@@ -174,9 +174,30 @@
 replaced and an exception is thrown (possibly at a later time when flush is
 called or the database is closed).
 
+=item add_spelling <word> <freqinc>
+
+Add a word to the spelling dictionary.
+
+If the word is already present, its frequency is increased.
+
+Parameters:
+    word        The word to add.
+    freqinc     How much to increase its frequency by (default 1).
+
+=item remove_spelling <word> <freqdec>
+
+Remove a word from the spelling dictionary.
+
+The word's frequency is decreased, and if would become zero or less
+then the word is removed completely.
+
+Parameters:
+    word        The word to remove.
+    freqdec     How much to decrease its frequency by (default 1).
+
 =item reopen
 
-Re-open the database. makes sure you have a fresh db handle.
+Re-open the database to ensure you are using the latest revision.
 
 =back
 

Modified: branches/upstream/libsearch-xapian-perl/current/t/index.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/t/index.t?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/t/index.t (original)
+++ branches/upstream/libsearch-xapian-perl/current/t/index.t Mon Feb 15 08:36:25 2010
@@ -32,6 +32,10 @@
 
   my $term = 'test';
   ok( $term = $stemmer->stem_word( $term ) );
+  if ($backend ne "inmemory") {
+    # inmemory doesn't implement spelling correction support.
+    $database->add_spelling( $term, 1 );
+  }
 
   my $docid;
   for my $num qw( one two three ) {
@@ -44,6 +48,13 @@
     $docs{$num}->add_posting( $num, 1 );
 
     $docs{$num}->add_value(0, $num);
+
+    if ($backend ne "inmemory") {
+      # inmemory doesn't implement spelling correction support.
+      $database->add_spelling( "x" . $term, 1 );
+      $database->add_spelling( $term, 1 );
+      $database->remove_spelling( "x" . $term, 1 );
+    }
     ok( $docid = $database->add_document( $docs{$num} ) );
   }
   $database->delete_document( $docid );

Modified: branches/upstream/libsearch-xapian-perl/current/t/parser.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/t/parser.t?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/t/parser.t (original)
+++ branches/upstream/libsearch-xapian-perl/current/t/parser.t Mon Feb 15 08:36:25 2010
@@ -6,7 +6,7 @@
 
 use Test;
 use Devel::Peek;
-BEGIN { plan tests => 53 };
+BEGIN { plan tests => 54 };
 use Search::Xapian qw(:standard);
 ok(1); # If we made it this far, we're ok.
 
@@ -29,7 +29,8 @@
 $qp->set_default_op( OP_AND );
 
 my $query;
-ok( $query = $qp->parse_query( 'one or two', FLAG_BOOLEAN|FLAG_BOOLEAN_ANY_CASE ) );
+ok( $query = $qp->parse_query( 'one or two', FLAG_BOOLEAN|FLAG_BOOLEAN_ANY_CASE|FLAG_SPELLING_CORRECTION ) );
+ok( not $qp->get_corrected_query_string());
 ok( $query->get_description(), "Xapian::Query((one:(pos=1) OR two:(pos=2)))" );
 
 ok( $query = $qp->parse_query( 'one OR (two AND three)' ) );

Modified: branches/upstream/libsearch-xapian-perl/current/t/search.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libsearch-xapian-perl/current/t/search.t?rev=52778&op=diff
==============================================================================
--- branches/upstream/libsearch-xapian-perl/current/t/search.t (original)
+++ branches/upstream/libsearch-xapian-perl/current/t/search.t Mon Feb 15 08:36:25 2010
@@ -6,7 +6,7 @@
 # change 'tests => 1' to 'tests => last_test_to_print';
 
 use Test::More;
-BEGIN { plan tests => 114 };
+BEGIN { plan tests => 115 };
 use Search::Xapian qw(:ops);
 
 #########################
@@ -55,6 +55,7 @@
 
 ok( $enq = $db->enquire( $query ), "db queries return ok"  );
 ok( $enq = $db->enquire( OP_OR, 'test', 'help' ), "in-line db queries return ok" );
+is( $db->get_spelling_suggestion( 'tost' ), 'test', "spelling suggestion ok" );
 
 ok( $query = Search::Xapian::Query->new(OP_SCALE_WEIGHT, $query, 3.14), "OP_SCALE_WEIGHT understood" );
 




More information about the Pkg-perl-cvs-commits mailing list