GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  PLUCENE::PLUGIN::ANALYZER::SNOWBALLANALYZER (3)

.ds Aq ’

NAME

Plucene::Plugin::Analyzer::SnowballAnalyzer - Stemmed analyzer with Lingua::Stem::Snowball and Lingua::StopWords

CONTENTS

DESCRIPTION

Filters StandardTokenizer with SnowballAnalyzer.

Change $Plucene::Plugin::Analysis::SnowballAnalyzer::LANG to the language of your choice. (see Lingua::Stem::Snowball documentation for all available languages).

EXAMPLE



  #!/usr/bin/perl
 
  use strict;
  use Plucene;
  use Plucene::Index::Writer;
  use Plucene::Plugin::Analyzer::SnowballAnalyzer;
  use Plucene::Search::IndexSearcher;
  use Plucene::QueryParser;
 
  $Plucene::Plugin::Analyzer::SnowballAnalyzer::LANG = fr;
 
  my $db = "plucene_index";
 
  my $writer = Plucene::Index::Writer->new($db, Plucene::Plugin::Analyzer::SnowballAnalyzer->new(), 1);
 
  $doc = Plucene::Document->new();
  $doc->add(Plucene::Document::Field->Keyword(filename => test2.html));
  $doc->add(Plucene::Document::Field->Text(title => Another file title));
  $doc->add(Plucene::Document::Field->UnStored(content => Nothing HERE. la folie...));
  $writer->add_document($doc);
 
  $doc = Plucene::Document->new();
  $doc->add(Plucene::Document::Field->Keyword(filename => test2.html));
  $doc->add(Plucene::Document::Field->Text(title => Fichier en franc\k:,ais));
  $doc->add(Plucene::Document::Field->UnStored(content => Vive le franc\k:,ais! Je t\aime tendrement...));
  $writer->add_document($doc);
 
  $writer->optimize;
 
  my $searcher = Plucene::Search::IndexSearcher->new($db);
  my $parser = Plucene::QueryParser->new({
        analyzer => Plucene::Plugin::Analyzer::SnowballAnalyzer->new(),
        default => content,
  });
  my $parsed = $parser->parse("la +france +TENDRE title:fichier");
 
  my @docs;
  my $hc = Plucene::Search::HitCollector->new(
        collect => sub {
                my ($self, $doc, $score) = @_;
                my $res = eval { $searcher->doc($doc); };
                push @docs, $res if res;
        },
  );
 
  $searcher->search_hc($parsed, $hc);
  my @results = map {{
        filename => $_->get(filename)->string,
        title => $_->get(title)->string,
  }} @docs;
 
  print "Results:\n";
  foreach my $result (@results) {
        print "\t$result->{title} ($result->{filename})\n";
  }



AUTHOR

Fabien POTENCIER, fabpot@cpan.org

LICENSE

You may distribute this code under the same terms as Plucene himself.

POD ERRORS

Hey! <B>The above document had some coding errors, which are explained below:B>
Around line 51: Non-ASCII character seen before =encoding in ’franc\k:,ais’));’. Assuming ISO8859-1
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 PLUCENE::PLUGIN::ANALYZER::SNOWBALLANALYZER (3) 2004-05-01

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.