r36491 - in /trunk/libsearch-xapian-perl: ./ Xapian/ debian/ examples/ t/

ryan52-guest at users.alioth.debian.org ryan52-guest at users.alioth.debian.org
Wed May 27 04:26:06 UTC 2009


Author: ryan52-guest
Date: Wed May 27 04:26:01 2009
New Revision: 36491

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=36491
Log:
New upstream release

Added:
    trunk/libsearch-xapian-perl/examples/full-indexer.pl
      - copied unchanged from r36490, branches/upstream/libsearch-xapian-perl/current/examples/full-indexer.pl
    trunk/libsearch-xapian-perl/examples/full-searcher.pl
      - copied unchanged from r36490, branches/upstream/libsearch-xapian-perl/current/examples/full-searcher.pl
    trunk/libsearch-xapian-perl/examples/simpleexpand.pl
      - copied unchanged from r36490, branches/upstream/libsearch-xapian-perl/current/examples/simpleexpand.pl
    trunk/libsearch-xapian-perl/examples/simpleindex.pl
      - copied unchanged from r36490, branches/upstream/libsearch-xapian-perl/current/examples/simpleindex.pl
    trunk/libsearch-xapian-perl/examples/simplematchdecider.pl
      - copied unchanged from r36490, branches/upstream/libsearch-xapian-perl/current/examples/simplematchdecider.pl
Modified:
    trunk/libsearch-xapian-perl/Changes
    trunk/libsearch-xapian-perl/MANIFEST
    trunk/libsearch-xapian-perl/META.yml
    trunk/libsearch-xapian-perl/README
    trunk/libsearch-xapian-perl/Xapian.pm
    trunk/libsearch-xapian-perl/Xapian/MSet.pm
    trunk/libsearch-xapian-perl/debian/changelog
    trunk/libsearch-xapian-perl/examples/simplesearch.pl
    trunk/libsearch-xapian-perl/t/tied.t

Modified: trunk/libsearch-xapian-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsearch-xapian-perl/Changes?rev=36491&op=diff
==============================================================================
--- trunk/libsearch-xapian-perl/Changes (original)
+++ trunk/libsearch-xapian-perl/Changes Wed May 27 04:26:01 2009
@@ -1,7 +1,23 @@
 Revision history for Perl extension Search::Xapian.
 
+1.0.13.1  Tue May 26 13:51:18 GMT 2009
+	[Changes contributed by Olly Betts]
+	- Deprecate Search::Xapian::MSet::matches() and make it issue a
+	  warning.  Please use Search::Xapian::MSet::items() instead.
+	- Add another translated example: simplematchdecider.pl
+
+1.0.13.0  Sat May 23 15:10:39 GMT 2009
+	[Changes contributed by Olly Betts]
+	- Add Search::Xapian::MSet::matches() method which returns an array
+	  tied to the MSet (much like Search::Xapian::Enquire::matches(), but
+	  you get access to the MSet object itself).
+	- Add new translated version of the simple examples from the Python
+	  bindings.
+	- Add more fully featured examples: full-indexer.pl and
+	  full-searcher.pl.
+
 1.0.12.0  Sun Apr 19 11:18:04 GMT 2009
-	[Changes contributed by Olly Betts] 
+	[Changes contributed by Olly Betts]
 	- Add handling of exceptions from Database::get_metadata() and methods
 	  of Enquire which might throw DatabaseModifiedError to address
 	  situation reported in ticket#284.

Modified: trunk/libsearch-xapian-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsearch-xapian-perl/MANIFEST?rev=36491&op=diff
==============================================================================
--- trunk/libsearch-xapian-perl/MANIFEST (original)
+++ trunk/libsearch-xapian-perl/MANIFEST Wed May 27 04:26:01 2009
@@ -84,5 +84,10 @@
 t/valuerange.t
 t/writabledatabase.t
 
+examples/full-indexer.pl
+examples/full-searcher.pl
+examples/simpleexpand.pl
+examples/simpleindex.pl
+examples/simplematchdecider.pl
 examples/simplesearch.pl
 META.yml                                 Module meta-data (added by MakeMaker)

Modified: trunk/libsearch-xapian-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsearch-xapian-perl/META.yml?rev=36491&op=diff
==============================================================================
--- trunk/libsearch-xapian-perl/META.yml (original)
+++ trunk/libsearch-xapian-perl/META.yml Wed May 27 04:26:01 2009
@@ -1,10 +1,13 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
-name:         Search-Xapian
-version:      1.0.12.0
-version_from: Xapian.pm
-installdirs:  site
-requires:
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.30_01
+--- #YAML:1.0
+name:                Search-Xapian
+version:             1.0.13.1
+abstract:            Perl XS frontend to the Xapian C++ search library.
+license:             ~
+author:              
+    - Alex Bowley <xapian-discuss at lists.xapian.org>
+generated_by:        ExtUtils::MakeMaker version 6.42
+distribution_type:   module
+requires:     
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3

Modified: trunk/libsearch-xapian-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsearch-xapian-perl/README?rev=36491&op=diff
==============================================================================
--- trunk/libsearch-xapian-perl/README (original)
+++ trunk/libsearch-xapian-perl/README Wed May 27 04:26:01 2009
@@ -1,4 +1,4 @@
-Search::Xapian version 1.0.12.0
+Search::Xapian version 1.0.13.1
 ===============================
 
 This is Search::Xapian, a Perl XS frontend to the Xapian C++ search library.

Modified: trunk/libsearch-xapian-perl/Xapian.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsearch-xapian-perl/Xapian.pm?rev=36491&op=diff
==============================================================================
--- trunk/libsearch-xapian-perl/Xapian.pm (original)
+++ trunk/libsearch-xapian-perl/Xapian.pm Wed May 27 04:26:01 2009
@@ -4,7 +4,7 @@
 use strict;
 use warnings;
 
-our $VERSION = '1.0.12.0';
+our $VERSION = '1.0.13.1';
 
 use Exporter 'import';
 

Modified: trunk/libsearch-xapian-perl/Xapian/MSet.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsearch-xapian-perl/Xapian/MSet.pm?rev=36491&op=diff
==============================================================================
--- trunk/libsearch-xapian-perl/Xapian/MSet.pm (original)
+++ trunk/libsearch-xapian-perl/Xapian/MSet.pm Wed May 27 04:26:01 2009
@@ -84,4 +84,16 @@
   }
 }
 
+sub items {
+  my $self = shift;
+  my @array;
+  tie( @array, 'Search::Xapian::MSet::Tied', $self );
+  return @array;
+}
+
+sub matches {
+    warn "Search::Xapian::MSet::matches() is deprecated - use Search::Xapian::MSet::items() method instead.\n";
+    return items(@_);
+}
+
 1;

Modified: trunk/libsearch-xapian-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsearch-xapian-perl/debian/changelog?rev=36491&op=diff
==============================================================================
--- trunk/libsearch-xapian-perl/debian/changelog (original)
+++ trunk/libsearch-xapian-perl/debian/changelog Wed May 27 04:26:01 2009
@@ -1,3 +1,9 @@
+libsearch-xapian-perl (1.0.13.1-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Ryan Niebur <ryanryan52 at gmail.com>  Tue, 26 May 2009 21:24:45 -0700
+
 libsearch-xapian-perl (1.0.12.0-1) unstable; urgency=low
 
   [ gregor herrmann ]

Modified: trunk/libsearch-xapian-perl/examples/simplesearch.pl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsearch-xapian-perl/examples/simplesearch.pl?rev=36491&op=diff
==============================================================================
--- trunk/libsearch-xapian-perl/examples/simplesearch.pl (original)
+++ trunk/libsearch-xapian-perl/examples/simplesearch.pl Wed May 27 04:26:01 2009
@@ -1,48 +1,76 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
+#
+# Simple command-line search script.
+#
+# Copyright (C) 2003 James Aylett
+# Copyright (C) 2004,2007,2009 Olly Betts
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
+# USA
 
 use strict;
+use Search::Xapian (':all');
 
-use ExtUtils::testlib;
-use Getopt::Std;
-use Search::Xapian qw(:ops);
-
-use vars qw( %opts );
-getopts('d:t:nh', \%opts);
-
-if( exists $opts{h} ) {
-  print <<EOF;
-Synopsis: Searches a Xapian database for a particular term.
-Usage: $0 -d testdb -t help
-Options:
-        -d : database directory
-        -t : search terms
-        -h : displays this help screen
-        -q : quiet; does not display document data
-EOF
-  exit 0;
+# We require at least two command line arguments.
+if (scalar @ARGV < 2) {
+    print STDERR "Usage: $0 PATH_TO_DATABASE QUERY\n";
+    exit(1);
 }
 
-if( !$opts{d} or !$opts{t} ) {
-  print "Usage: $0 -d [database dir] -t [search terms]\n";
-  print "Try $0 -h for further information\n";
-  exit 0;
+eval {
+    # Open the database for searching.
+    my $database = Search::Xapian::Database->new(shift @ARGV);
+
+    # Start an enquire session.
+    my $enquire = Search::Xapian::Enquire->new($database);
+
+    # Combine the rest of the command line arguments with spaces between
+    # them, so that simple queries don't have to be quoted at the shell
+    # level.
+    my $query_string = join ' ', @ARGV;
+
+    # Parse the query string to produce a Xapian::Query object.
+    my $qp = Search::Xapian::QueryParser->new();
+    my $stemmer = Search::Xapian::Stem->new("english");
+    $qp->set_stemmer($stemmer);
+    $qp->set_database($database);
+    $qp->set_stemming_strategy(STEM_SOME);
+    my $query = $qp->parse_query($query_string);
+    print "Parsed query is: $query\n";
+
+    # Find the top 10 results for the query.
+    $enquire->set_query($query);
+    my $mset = $enquire->get_mset(0, 10);
+
+    # Display the results.
+    printf "%i results found.\n", $mset->get_matches_estimated();
+    printf "Results 1-%i:\n", $mset->size();
+
+    # In 1.0.13.0 and newer you'll be able to replace this with:
+    # foreach my $m ($mset->matches()) {
+    foreach my $m (tie_mset($mset)) {
+        printf "%i: %i%% docid=%i [%s]\n", $m->get_rank() + 1, $m->get_percent(), $m->get_docid(), $m->get_document()->get_data();
+    }
+};
+if ($@) {
+    print STDERR "Exception: $@\n";
+    exit(1);
 }
 
-my $db = Search::Xapian::Database->new( $opts{d} );
-my @terms = split ',', $opts{t};
-my $enq = $db->enquire( OP_OR, @terms );
-
-printf "Parsing query '%s'\n", $enq->get_query()->get_description();
-
-my @matches = $enq->matches(0, 10);
-
-print scalar(@matches) . " results found\n";
-
-foreach my $match ( @matches ) {
-  printf "ID %d %d%%", $match->get_docid(), $match->get_percent();
-  if( !defined( $opts{n} ) ) {
-    my $doc = $match->get_document();
-    printf " [ %s ]", $doc->get_data();
-  }
-  print "\n";
+sub tie_mset {
+    my @a;
+    tie( @a, 'Search::Xapian::MSet::Tied', shift );
+    return @a;
 }

Modified: trunk/libsearch-xapian-perl/t/tied.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libsearch-xapian-perl/t/tied.t?rev=36491&op=diff
==============================================================================
--- trunk/libsearch-xapian-perl/t/tied.t (original)
+++ trunk/libsearch-xapian-perl/t/tied.t Wed May 27 04:26:01 2009
@@ -7,7 +7,7 @@
 
 use Test;
 use Devel::Peek;
-BEGIN { plan tests => 6 };
+BEGIN { plan tests => 19 };
 use Search::Xapian qw(:ops);
 
 #########################
@@ -24,8 +24,10 @@
 
 $enq->set_query( $query );
 
+my $mset;
+ok( $mset = $enq->get_mset(0, 10) );
 my @matches;
-ok( @matches = $enq->matches(0, 10) );
+ok( @matches = $mset->items() );
 my $match;
 ok( $match = $matches[0] );
 ok( $match->get_docid() );
@@ -33,8 +35,31 @@
 
 $matches[0] = 34;
 
+# Check that MSet::matches() gives a warning - it's deprecated in favour of
+# MSet::items() - but still works like items() does.
+my $warned = 0;
+my $old_sig_warn = $SIG{'__WARN__'};
+$SIG{'__WARN__'} = sub { ++$warned; };
+ok( @matches = $mset->matches() );
+ok( $warned == 1 );
+$SIG{'__WARN__'} = $old_sig_warn;
+ok( $match = $matches[0] );
+ok( $match->get_docid() );
+ok( $match->get_percent() );
+
 my $doc;
 ok( $doc = $match->get_document() );
 ok( $doc->get_data() );
 
-1;
+ok( exists $matches[1] );
+ok( !exists $matches[10] );
+ok( exists $matches[-1] );
+
+my @ematches;
+ok( @ematches = $enq->matches(0, 2) );
+
+ok( $match = $ematches[0] );
+ok( $match->get_docid() );
+ok( $match->get_percent() );
+
+1;




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