[Koha-cvs] CVS: koha/C4 SearchMarc.pm,1.12,1.13
Paul POULAIN
tipaul at users.sourceforge.net
Fri Apr 16 09:28:25 CEST 2004
Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28364/C4
Modified Files:
SearchMarc.pm
Log Message:
improving Search :
* adding "suggestion", that popup a windows. The popup windows shows, for each word entered in the search form, the 10 words that sounds like the word entered, and that are used most often.
* fixes some minor bugs
Still to do :
* good support of ' and ,
Index: SearchMarc.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/SearchMarc.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** SearchMarc.pm 14 Apr 2004 19:45:48 -0000 1.12
--- SearchMarc.pm 16 Apr 2004 07:28:22 -0000 1.13
***************
*** 53,60 ****
@ISA = qw(Exporter);
! @EXPORT = qw(&catalogsearch &findseealso);
# make all your functions, whether exported or not;
sub findseealso {
my ($dbh, $fields) = @_;
--- 53,78 ----
@ISA = qw(Exporter);
! @EXPORT = qw(&catalogsearch &findseealso &findsuggestion);
# make all your functions, whether exported or not;
+ sub findsuggestion {
+ my ($dbh,$values) = @_;
+ my $sth = $dbh->prepare("SELECT count( * ) AS total, word FROM marc_word WHERE sndx_word = soundex( ? ) AND word <> ? GROUP BY word ORDER BY total DESC");
+ my @results;
+ for(my $i = 0 ; $i <= $#{$values} ; $i++) {
+ if (length(@$values[$i]) >=5) {
+ $sth->execute(@$values[$i],@$values[$i]);
+ my $resfound = 1;
+ my @resline;
+ while ((my ($count,$word) = $sth->fetchrow) and $resfound <=10) {
+ push @results, "@$values[$i]|$word|$count";
+ # $results{@$values[$i]} = \@resline;
+ $resfound++;
+ }
+ }
+ }
+ return \@results;
+ }
sub findseealso {
my ($dbh, $fields) = @_;
More information about the Koha-cvs
mailing list