| Search-Tools documentation | Contained in the Search-Tools distribution. |
Search::Tools - high-performance tools for building search applications
use Search::Tools;
my $string = 'the quik brown fox';
my $qparser = Search::Tools->parser();
my $query = $qparser->parse($string);
my $snipper = Search::Tools->snipper(query => $query);
my $hiliter = Search::Tools->hiliter(query => $query);
my $spellcheck = Search::Tools->spellcheck(query_parser => $qparser);
my $suggestions = $spellcheck->suggest($string);
for my $s (@$suggestions) {
if (! $s->{suggestions}) {
# $s->{word} was spelled correctly
}
elsif (@{ $s->{suggestions} }) {
printf "Did you mean: %s\n", join(' or ', @{$s->{suggestions}}));
}
}
for my $result (@search_results) {
print $hiliter->light( $snipper->snip( $result->summary ) );
}
Search::Tools is a set of utilities for building search applications. Rather than adhering to a particular search application or framework, the goal of Search::Tools is to provide general-purpose methods for common search application features. Think of Search::Tools like a toolbox rather than a hammer.
Examples include:
Parsing search queries for the meaningful terms
Rich regular expressions for locating terms in the original indexed documents
Contextual snippets showing query terms
Highlighting of terms in context
Spell check terms and suggestions of alternate spellings.
Search::Tools is derived from some of the features in HTML::HiLiter and SWISH::HiLiter, but has been re-written with an eye to accomodating more general purpose features.
Returns a Search::Tools::Parser object, passing args to new().
Deprecated. Use parser() instead.
Returns a Search::Tools::HiLiter object, passing args to new().
Returns a Search::Tools::Snipper object, passing args to new().
Same as:
Search::Tools::Transliterate->new()->convert( $str )
Returns a Search::Tools::SpellCheck object, passing args to new().
XS debugging help. Same as using Devel::Peek.
Perl 5.8.3 or later is required. This is for full UTF-8 support.
The following CPAN modules are required:
The following CPAN modules are recommended for the full set of features and for performance.
See also the specific module documentation for individual requirements.
The public API has changed as of version 0.24. The following classes are now deprecated:
Search::Tools::Keywords Search::Tools::RegExp Search::Tools::RegExp::Keywords Search::Tools::RegExp::Keyword
The following Search::Tools method is deprecated:
regexp()
The following classes are new as of version 0.24:
Search::Tools::HeatMap Search::Tools::Query Search::Tools::QueryParser Search::Tools::RegEx Search::Tools::Token Search::Tools::TokenList Search::Tools::TokenListPP Search::Tools::TokenListUtils Search::Tools::TokenPP Search::Tools::Tokenizer
See the tests in t/ and the example scripts in example/.
Peter Karman <karman@cpan.org>
The original idea and regular expression builder comes from HTML::HiLiter by the same author, copyright 2004 by Cray Inc.
Thanks to Atomic Learning www.atomiclearning.com
for sponsoring the development of some of these modules.
Please report any bugs or feature requests to bug-search-tools at rt.cpan.org, or through
the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Search-Tools.
I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Search::Tools
You can also look for information at:
Copyright 2006-2009 by Peter Karman.
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
HTML::HiLiter, SWISH::HiLiter, Rose::Object, Class::XSAccessor, Text::Aspell
| Search-Tools documentation | Contained in the Search-Tools distribution. |
package Search::Tools; use 5.008_003; use strict; use warnings::register; use Carp; our $VERSION = '0.45'; use XSLoader; XSLoader::load( 'Search::Tools', $VERSION ); sub parser { my $class = shift; require Search::Tools::QueryParser; return Search::Tools::QueryParser->new(@_); } sub regexp { my $class = shift; warnings::warn( "as of version 0.24 you should use parser() instead of regexp()") if warnings::enabled(); my %extra = @_; my $q = delete( $extra{query} ) || croak "query required"; return $class->parser(%extra)->parse($q); } sub hiliter { my $class = shift; require Search::Tools::HiLiter; return Search::Tools::HiLiter->new(@_); } sub snipper { my $class = shift; require Search::Tools::Snipper; return Search::Tools::Snipper->new(@_); } sub transliterate { my $class = shift; require Search::Tools::Transliterate; return Search::Tools::Transliterate->new->convert(@_); } sub spellcheck { my $class = shift; require Search::Tools::SpellCheck; return Search::Tools::SpellCheck->new(@_); } 1; __END__