/[Semantic-Engine]/EPrints/search.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /EPrints/search.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1 by dpavlin, Fri Jun 29 09:08:58 2007 UTC revision 8 by dpavlin, Fri Jun 29 14:53:14 2007 UTC
# Line 11  Line 11 
11  use strict;  use strict;
12  use CGI::Carp qw(fatalsToBrowser);  use CGI::Carp qw(fatalsToBrowser);
13  use Semantic::API;  use Semantic::API;
 use DBI;  
14  use CGI;  use CGI;
15  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
16  use EPrints;  use EPrints;
17  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
18    use lib '/home/dpavlin/stem-hr/';
19    use StemHR;
20    
21  my $abs_path = abs_path( $0 );  my $abs_path = abs_path( $0 );
22  $abs_path =~ s!/[^/]*$!/!;  #!fix-vim  $abs_path =~ s!/[^/]*$!/!;  #!fix-vim
# Line 23  $abs_path =~ s!/[^/]*$!/!;  #!fix-vim Line 24  $abs_path =~ s!/[^/]*$!/!;  #!fix-vim
24  #############################################################  #############################################################
25  my $COLLECTION = 'EPrints';  my $COLLECTION = 'EPrints';
26  my ( @TERMS, @RESULTS );  my ( @TERMS, @RESULTS );
27  my ( $RESULTS_TO_DISPLAY, $TERMS_TO_DISPLAY ) = ( 10, 10 );  my ( $RESULTS_TO_DISPLAY, $TERMS_TO_DISPLAY ) = ( 20, 20 );
28  #############################################################  #############################################################
29    
30    
# Line 34  my $cgi = new CGI; Line 35  my $cgi = new CGI;
35  my $start = $cgi->param( 'start' ) || 0;  my $start = $cgi->param( 'start' ) || 0;
36  my $query = $cgi->param( 'query' ) || '';  my $query = $cgi->param( 'query' ) || '';
37  my $similar = $cgi->param( 'similar' ) || '';  my $similar = $cgi->param( 'similar' ) || '';
38    my $slogovi = $cgi->param( 'slogovi' );
39    my $stem = $cgi->param( 'stem' );
40    
41  my $charset='iso-8859-2';  my $charset='iso-8859-2';
42    
43    my $full_query = $query;
44    $full_query .= " " . EPrints::slogovi( $query ) if ($slogovi);
45    $full_query .= " " . StemHR->stem( $query ) if ($stem);
46    
47  ##############################  ##############################
48  #       Start the HTML output  #       Start the HTML output
# Line 55  print qq|<?xml version="1.0" encoding="$ Line 61  print qq|<?xml version="1.0" encoding="$
61      <p>      <p>
62        <input type="text" name="query" value="$query" />        <input type="text" name="query" value="$query" />
63        <input type="submit" />        <input type="submit" />
64              |, $cgi->checkbox( -name => 'stem' ), $cgi->checkbox( -name => 'slogovi' ), qq|
65      </p>\n|;      </p>\n|;
66    
67    
# Line 71  if( $query || $similar ) { Line 78  if( $query || $similar ) {
78    
79      my ($results, $terms);      my ($results, $terms);
80          if ( $query ) {          if ( $query ) {
81          ($results, $terms) = $semantic->semantic_search( $query );          ($results, $terms) = $semantic->semantic_search( $full_query );
82          } else {          } else {
83          ($results, $terms) = $semantic->find_similar( $similar );          ($results, $terms) = $semantic->find_similar( $similar );
84          }          }
# Line 85  warn "terms = ",dump( $terms ); Line 92  warn "terms = ",dump( $terms );
92          my @sorted_terms = sort { $terms->{$b} <=> $terms->{$a} } keys %$terms;          my @sorted_terms = sort { $terms->{$b} <=> $terms->{$a} } keys %$terms;
93          my @top_terms = splice( @sorted_terms, $start, $TERMS_TO_DISPLAY );          my @top_terms = splice( @sorted_terms, $start, $TERMS_TO_DISPLAY );
94                    
95            print "<p>Full query: $full_query</p>\n";
96          print "<p>Related Terms: ". ( join ", ", @top_terms ) ."</p>\n";          print "<p>Related Terms: ". ( join ", ", @top_terms ) ."</p>\n";
97          print "<hr />\n";          print "<hr />\n";
98    
# Line 108  warn dump( @display_results ); Line 116  warn dump( @display_results );
116          print $semantic->paginate( "?query=$query;similar=$similar", $start, scalar keys %$results, $RESULTS_TO_DISPLAY);          print $semantic->paginate( "?query=$query;similar=$similar", $start, scalar keys %$results, $RESULTS_TO_DISPLAY);
117          foreach my $id ( @display_results ){          foreach my $id ( @display_results ){
118                  EPrints->id( $id );                  EPrints->id( $id );
119          print "<p>$i. <b>", EPrints->lookup( 'title' ), "</b> <em>", sprintf("%.2f",$results->{$id}), "</em> <a href=\"?similar=$id\">similar</a></p>\n";          print "<p>$i. <b>", EPrints->lookup( 'title' ), "</b>";
120                    print "$id <em>", sprintf("%.2f",$results->{$id}), "</em> <a href=\"?similar=$id\">similar</a></p>\n";
121          print "<p>";          print "<p>";
122  #               print $semantic->summarize($id);  #               print $semantic->summarize($id);
123                    print "</p><p>Keywords: ", EPrints->lookup('keywords'), "</p><p>";
124                  print "<small>", EPrints->lookup('abstract'), "</small>";                  print "<small>", EPrints->lookup('abstract'), "</small>";
125                  print "</p>\n";                  print "</p>\n";
126          $i++;          $i++;

Legend:
Removed from v.1  
changed lines
  Added in v.8

  ViewVC Help
Powered by ViewVC 1.1.26