[ic] Intercept and correct mv_searchspec
Mike Heins
mike at perusion.com
Tue Jun 26 15:53:53 UTC 2012
Quoting IC (ic at tvcables.co.uk):
> Not sure this made the list so re-sending...
>
> Hi folks,
>
> I am trying to intercept mv_searchspec from the small search component and
> correct a common spelling difference:-
>
> So far this is my non working code in the small search component:-
>
>
> <INPUT MAXLENGTH=30 NAME="[value mv_searchspec]" type=text size=15>
> [tmp sspec][perl]
> my $correct = $Values->{mv_searchspec}->[0];
> $correct =~ s/adaptor/adapter/g;
> return $correct;
> [/perl][/tmp]
>
> <input type=hidden name=mv_searchspec value=[scratch sspec]>
>
> It doesn't work, please help!
You could do in catalog.cfg:
Filter mv_searchspec spells
CodeDef spells Filter
CodeDef spells Spell check search specs
CodeDef spells Routine <<EOR
sub {
my $spec = shift;
my %spell = qw/
adaptor adapter
beleive believe
recieve receive
/;
my @finds = keys %spell;
my $finds = join "|", @finds;
$spec =~ s{\b($finds)\b}{ $spell{ lc $1 } || $1}eig;
return $spec;
}
EOR
I personally think a better approach is to do another post-search
to check for commonly misspelled words, then present the now-standard
Google meme "Showing results for adapter -- search for adaptor instead".
But this might work in the meantime.
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.765.253.4194 <mike at perusion.com>
There's nothing sweeter than life nor more precious than time.
-- Barney
More information about the interchange-users
mailing list