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;
16 use OpenILS::Application::Search::CNBrowse;
19 use OpenILS::Application::AppUtils;
21 use Time::HiRes qw(time);
22 use OpenSRF::EX qw(:try);
26 # Houses generic search utilites
29 OpenILS::Application::Search::Z3950->initialize();
30 OpenILS::Application::Search::Zips->initialize();
31 OpenILS::Application::Search::Biblio->initialize();
36 # ------------------------------------------------------------------
37 # Create custome dictionaries like so:
38 # aspell --lang=en create master ./oils_authority.dict < /tmp/words
39 # where /tmp/words is a space separated list of words
40 # ------------------------------------------------------------------
42 __PACKAGE__->register_method(
43 method => "spellcheck",
44 api_name => "open-ils.search.spellcheck");
46 my $speller = Text::Aspell->new();
49 my( $self, $client, $phrase ) = @_;
51 my $conf = OpenSRF::Utils::SettingsClient->new;
53 if( my $dict = $conf->config_value(
54 "apps", "open-ils.search", "app_settings", "spelling_dictionary")) {
55 $speller->set_option('master', $dict);
56 $logger->debug("spelling dictionary set to $dict");
60 return \@resp unless $phrase;
61 for my $word (split(/\s+/,$phrase) ) {
65 suggestions => ($speller->check($word)) ? undef : [$speller->suggest($word)]