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 ) ); }
As of version 1.000 Search::Tools uses Moo and Class::XSAccessor.
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().
Reads contents of filename into a scalar variable. Similar to File::Slurp, but will handle compressed files (.gz or .bz2) transparently using IO::Uncompress.
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 non-core 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 removed:
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>
<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.
www.atomiclearning.com
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.
bug-search-tools at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Search::Tools
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Search-Tools
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Search-Tools
CPAN Ratings
http://cpanratings.perl.org/d/Search-Tools
Search CPAN
http://search.cpan.org/dist/Search-Tools/
Copyright 2006-2009, 2014 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, Moo, Class::XSAccessor, Text::Aspell
To install Search::Tools, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Search::Tools
CPAN shell
perl -MCPAN -e shell install Search::Tools
For more information on module installation, please visit the detailed CPAN module installation guide.