1 package OpenILS::Application::Search;
2 use base qw/OpenSRF::Application/;
3 use strict; use warnings;
5 use OpenSRF::Utils::Logger qw(:logger);
7 use OpenILS::Utils::Fieldmapper;
8 use OpenILS::Utils::ModsParser;
9 use OpenSRF::Utils::SettingsClient;
10 use OpenSRF::Utils::Cache;
12 use OpenILS::Application::Search::Biblio;
13 use OpenILS::Application::Search::Authority;
14 use OpenILS::Application::Search::Z3950;
15 use OpenILS::Application::Search::Zips;
18 use OpenILS::Application::AppUtils;
20 use Time::HiRes qw(time);
21 use OpenSRF::EX qw(:try);
25 # Houses generic search utilites
28 OpenILS::Application::Search::Z3950->initialize();
29 OpenILS::Application::Search::Zips->initialize();
30 OpenILS::Application::Search::Biblio->initialize();
35 # ------------------------------------------------------------------
36 # Create custome dictionaries like so:
37 # aspell --lang=en create master ./oils_authority.dict < /tmp/words
38 # where /tmp/words is a space separated list of words
39 # ------------------------------------------------------------------
41 __PACKAGE__->register_method(
42 method => "spellcheck",
43 api_name => "open-ils.search.spellcheck");
45 my $speller = Text::Aspell->new();
48 my( $self, $client, $phrase ) = @_;
50 my $conf = OpenSRF::Utils::SettingsClient->new;
52 if( my $dict = $conf->config_value(
53 "apps", "open-ils.search", "app_settings", "spelling_dictionary")) {
54 $speller->set_option('master', $dict);
55 $logger->debug("spelling dictionary set to $dict");
59 return \@resp unless $phrase;
60 for my $word (split(/\s+/,$phrase) ) {
64 suggestions => ($speller->check($word)) ? undef : [$speller->suggest($word)]