Text::Query::ParseSimple.3pm

Langue: en

Autres versions - même langue

Version: 1999-06-20 (debian - 07/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Text::Query::ParseSimple - Parse AltaVista simple query syntax

SYNOPSIS

   use Text::Query;
   my $q=new Text::Query('hello and world',
                         -parse => 'Text::Query::ParseSimple',
                         -solve => 'Text::Query::SolveSimpleString',
                         -build => 'Text::Query::BuildSimpleString');
 
 
 

DESCRIPTION

This module provides an object that parses a string containing a Boolean query expression similar to an AltaVista ``simple query''. Elements of the query expression may be assigned weights.

It's base class is Text::Query::Parse;

Query expressions are compiled into an internal form when a new object is created or the "prepare" method is called; they are not recompiled on each match.

Query expressions consist of words (sequences of non-whitespace) or phrases (quoted strings) separated by whitespace. Words or phrases prefixed with a "+" must be present for the expression to match; words or phrases prefixed with a "-" must be absent for the expression to match.

Words or phrases may optionally be followed by a number in parentheses (no whitespace is allowed between the word or phrase and the parenthesized number). This number specifies the weight given to the word or phrase. If a weight is not given, a weight of 1 is assumed.

EXAMPLES

   use Text::Query;
   my $q=new Text::Query('+hello world',
                         -solve => 'Text::Query::SolveSimpleString',
                         -build => 'Text::Query::BuildSimpleString');
   die "bad query expression" if not defined $q;
   $count=$q->match;
   ...
   $q->prepare('goodbye adios -"ta ta"', -litspace=>1);
   #requires single space between the two ta's
   if ($q->match($line, -case=>1)) {
   #doesn't match "Goodbye"
   ...
   $q->prepare('\\bintegrate\\b', -regexp=>1);
   #won't match "disintegrated"
   ...
   $q->prepare('information(2) retrieval');
   #information has twice the weight of retrieval
 
 
 

SEE ALSO

Text::Query(3) Text::Query::Parse(3)

AUTHORS

Eric Bohlman (ebohlman@netcom.com)

Loic Dachary (loic@senga.org)