--- EPrints/search.cgi 2007/06/30 12:50:56 16 +++ EPrints/search.cgi 2007/07/02 12:55:49 18 @@ -15,6 +15,7 @@ use Data::Dump qw/dump/; use EPrints; use Cwd qw/abs_path/; +use KinoSearch::Simple; use lib '/home/dpavlin/stem-hr/'; use StemHR; @@ -39,6 +40,7 @@ my $similar = $cgi->param( 'similar' ) || ''; my $slogovi = $cgi->param( 'slogovi' ) || ''; my $stem = $cgi->param( 'stem' ) || ''; +my $kino = $cgi->param( 'kino' ); my $charset='iso-8859-2'; @@ -79,9 +81,30 @@ database => "$abs_path/eprints.db", collection => $COLLECTION ); + my $score_ponder; + my ($results, $terms); if ( $query ) { ($results, $terms) = $semantic->semantic_search( $full_query ); + + my $kino = KinoSearch::Simple->new( + path => 'kinoindex/', + language => 'ru', + ); + + my $total_hits = $kino->search( + query => $query, + offset => 0, + num_wanted => 10, + ); + + print qq|
KinoSearch hits $total_hits for $query\n
    |; + while ( my $hit = $kino->fetch_hit_hashref ) { + print qq|
  1. $hit->{title} $hit->{score}
  2. \n|; + $score_ponder->{ $hit->{id} } = $hit->{score}; + } + print qq|
|; + } else { ($results, $terms) = $semantic->find_similar( $similar ); } @@ -92,7 +115,12 @@ ################################## # TERM BASED CALCULATIONS ################################## - my @sorted_terms = sort { $terms->{$b} <=> $terms->{$a} } keys %$terms; + my @sorted_terms = sort { + my ( $sb, $sa ) = ( $terms->{$b}, $terms->{$a} ); + $sb *= $score_ponder->{$b} if $score_ponder->{$b}; + $sa *= $score_ponder->{$a} if $score_ponder->{$a}; + $sb <=> $sa; + } keys %$terms; my @top_terms = splice( @sorted_terms, $start, $TERMS_TO_DISPLAY ); warn "top_terms = ", dump( @top_terms ) if $debug; @@ -121,7 +149,7 @@ print $semantic->paginate( "?query=$query;similar=$similar;stem=$stem;slogovi=$slogovi", $start, scalar keys %$results, $RESULTS_TO_DISPLAY); foreach my $id ( @display_results ){ EPrints->id( $id ); - print "

$i. ", EPrints->lookup( 'title' ), ""; + print "

$i. ", EPrints->lookup( 'title' ), ""; print "| score: ", sprintf("%.2f",$results->{$id}), " | id: $id | similar | "; my ($type,$uri) = EPrints->fulltext; print qq|$type|;