/[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 4 by dpavlin, Fri Jun 29 09:52:53 2007 UTC revision 16 by dpavlin, Sat Jun 30 12:50:56 2007 UTC
# Line 15  use CGI; Line 15  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 $debug = 1;
22    
23  my $abs_path = abs_path( $0 );  my $abs_path = abs_path( $0 );
24  $abs_path =~ s!/[^/]*$!/!;  #!fix-vim  $abs_path =~ s!/[^/]*$!/!;  #!fix-vim
# Line 22  $abs_path =~ s!/[^/]*$!/!;  #!fix-vim Line 26  $abs_path =~ s!/[^/]*$!/!;  #!fix-vim
26  #############################################################  #############################################################
27  my $COLLECTION = 'EPrints';  my $COLLECTION = 'EPrints';
28  my ( @TERMS, @RESULTS );  my ( @TERMS, @RESULTS );
29  my ( $RESULTS_TO_DISPLAY, $TERMS_TO_DISPLAY ) = ( 10, 10 );  my ( $RESULTS_TO_DISPLAY, $TERMS_TO_DISPLAY ) = ( 20, 20 );
30  #############################################################  #############################################################
31    
32    
# Line 33  my $cgi = new CGI; Line 37  my $cgi = new CGI;
37  my $start = $cgi->param( 'start' ) || 0;  my $start = $cgi->param( 'start' ) || 0;
38  my $query = $cgi->param( 'query' ) || '';  my $query = $cgi->param( 'query' ) || '';
39  my $similar = $cgi->param( 'similar' ) || '';  my $similar = $cgi->param( 'similar' ) || '';
40    my $slogovi = $cgi->param( 'slogovi' ) || '';
41    my $stem = $cgi->param( 'stem' ) || '';
42    
43  my $charset='iso-8859-2';  my $charset='iso-8859-2';
44    
45  my $full_query = "$query " . join(" ", EPrints::slogovi( $query ));  my $full_query = $query;
46    $full_query .= " " . EPrints->slogovi( $query ) if ($slogovi);
47    $full_query .= " " . StemHR->stem( $query ) if ($stem);
48    
49  ##############################  ##############################
50  #       Start the HTML output  #       Start the HTML output
# Line 53  print qq|<?xml version="1.0" encoding="$ Line 61  print qq|<?xml version="1.0" encoding="$
61  <body>  <body>
62    <form method="get" action="">    <form method="get" action="">
63      <p>      <p>
64        <input type="text" name="query" value="$query" />        Enter bunch of related terms to documents you are trying to find:
65        <input type="submit" />        <br/><input type="text" name="query" value="$query" size="80">
66          <br/><input type="submit" />
67              |, $cgi->checkbox( -name => 'stem' ), $cgi->checkbox( -name => 'slogovi' ), qq|
68      </p>\n|;      </p>\n|;
69    
70    
# Line 76  if( $query || $similar ) { Line 86  if( $query || $similar ) {
86          ($results, $terms) = $semantic->find_similar( $similar );          ($results, $terms) = $semantic->find_similar( $similar );
87          }          }
88    
89  warn "results = ",dump( $results );  warn "results = ",dump( $results ) if $debug;
90  warn "terms = ",dump( $terms );  warn "terms = ",dump( $terms ) if $debug;
91                    
92          ##################################          ##################################
93          #       TERM BASED CALCULATIONS          #       TERM BASED CALCULATIONS
94          ##################################          ##################################
95          my @sorted_terms = sort { $terms->{$b} <=> $terms->{$a} } keys %$terms;          my @sorted_terms = sort { $terms->{$b} <=> $terms->{$a} } keys %$terms;
96          my @top_terms = splice( @sorted_terms, $start, $TERMS_TO_DISPLAY );          my @top_terms = splice( @sorted_terms, $start, $TERMS_TO_DISPLAY );
97            
98    warn "top_terms = ", dump( @top_terms ) if $debug;
99    
100          print "<p>Full query: $full_query</p>\n";          print "<p>Full query: $full_query</p>\n";
101          print "<p>Related Terms: ". ( join ", ", @top_terms ) ."</p>\n";          print "<p>Related Terms: ". ( join ", ", @top_terms ) ."</p>\n";
102          print "<hr />\n";          print "<hr />\n";
# Line 99  warn "terms = ",dump( $terms ); Line 111  warn "terms = ",dump( $terms );
111      my @sorted_results = sort { $results->{$b} <=> $results->{$a} } keys %$results;      my @sorted_results = sort { $results->{$b} <=> $results->{$a} } keys %$results;
112          my @display_results = splice( @sorted_results, $start, $RESULTS_TO_DISPLAY );          my @display_results = splice( @sorted_results, $start, $RESULTS_TO_DISPLAY );
113                    
114  warn dump( @display_results );    warn "display results = ", dump( @display_results ) if $debug;
115                    
116          ##################################          ##################################
117          #       Access the storage engine to          #       Access the storage engine to
118          #       retrieve the title and text          #       retrieve the title and text
119          ##################################          ##################################
120          my $i = 1 + $start;          my $i = 1 + $start;
121          print $semantic->paginate( "?query=$query;similar=$similar", $start, scalar keys %$results, $RESULTS_TO_DISPLAY);          print $semantic->paginate( "?query=$query;similar=$similar;stem=$stem;slogovi=$slogovi", $start, scalar keys %$results, $RESULTS_TO_DISPLAY);
122          foreach my $id ( @display_results ){          foreach my $id ( @display_results ){
123                  EPrints->id( $id );                  EPrints->id( $id );
124          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>";
125          print "<p>";                  print "| score: <em>", sprintf("%.2f",$results->{$id}), "</em> | id: $id | <a href=\"?similar=$id\">similar</a> | ";
126                    my ($type,$uri) = EPrints->fulltext;
127                    print qq|<a href="$uri">$type</a>|;
128                    print "</p>\n";
129                    print "<p>";
130  #               print $semantic->summarize($id);  #               print $semantic->summarize($id);
131                    print "</p><p>Keywords: ", EPrints->lookup('keywords'), "</p><p>";
132                  print "<small>", EPrints->lookup('abstract'), "</small>";                  print "<small>", EPrints->lookup('abstract'), "</small>";
133                  print "</p>\n";                  print "</p>\n";
134          $i++;                  $i++;
135          }          }
136    
137  }        }      

Legend:
Removed from v.4  
changed lines
  Added in v.16

  ViewVC Help
Powered by ViewVC 1.1.26