/[Semantic-Engine]/EPrints/index.pl
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/index.pl

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

revision 14 by dpavlin, Fri Jun 29 22:54:51 2007 UTC revision 17 by dpavlin, Sat Jun 30 13:46:51 2007 UTC
# Line 6  use Data::Dump qw/dump/; Line 6  use Data::Dump qw/dump/;
6    
7  use EPrints qw/_x/;  use EPrints qw/_x/;
8    
 use lib '/home/dpavlin/stem-hr/';  
 use StemHR;  
   
9  my $debug = shift @ARGV;  my $debug = shift @ARGV;
10  my $use_score = 0;  my $use = {
11            score => 1,
12            stem => 1,
13            slogovi => 1,
14    };
15    
16  my $dbh = EPrints->dbh;  my $dbh = EPrints->dbh;
17  my $sth = $dbh->prepare(qq{  my $sth = $dbh->prepare(qq{
# Line 18  SELECT Line 19  SELECT
19          archive_title.eprintid as id,          archive_title.eprintid as id,
20          title          title
21  FROM archive_title  FROM archive_title
22    WHERE
23            lang = 'hr'
24  }) || die $dbh->errstr();  }) || die $dbh->errstr();
25  $sth->execute() || die $sth->errstr();  $sth->execute() || die $sth->errstr();
26    
# Line 38  $indexer->set_default_encoding( "iso-885 Line 41  $indexer->set_default_encoding( "iso-885
41  my $total = 0;  my $total = 0;
42    
43  while (my $row = $sth->fetchrow_hashref ) {  while (my $row = $sth->fetchrow_hashref ) {
44          EPrints->id( $row->{id} );          my $id = $row->{id};
45            EPrints->id( $id );
46          my $parts = {          my $parts = {
47                  title => [ _x( $row->{title} ), 4 ],                  title => [ _x( $row->{title} ), 3 ],
48                  keywords => [ EPrints->lookup( 'keywords' ), 3 ],                  keywords => [ EPrints->lookup( 'keywords' ), 2 ],
49                  abstract => [ EPrints->lookup( 'abstract' ), 2 ],                  abstract => [ EPrints->lookup( 'abstract' ), 1 ],
50  #               content => [ EPrints->fulltext_content, 1 ],  #               content => [ EPrints->fulltext_content, 1 ],
51          };          };
52    
53            my $skip = 0;
54            foreach my $part ( qw/title keywords abstract/ ) {
55                    if ( ! $parts->{$part}->[0] ) {
56                            warn "skipped $id doesn't have required part $part\n";
57                            $skip = 1;
58                            last;
59                    }
60            }
61            next if $skip;
62    
63          my $body = '';          my $body = '';
64    
65          foreach my $part ( qw/title keywords abstract content/ ) {          foreach my $part ( qw/title keywords abstract content/ ) {
66                  my $content = $parts->{$part}->[0];                  my $content = $parts->{$part}->[0] || next;
67                  next unless defined $content;  
68                                    if ( $use->{slogovi} ) {
69  #               $content = StemHR->stem( $content );                          $body .= ' ' . EPrints->slogovi( $content );
70                  $content = EPrints->slogovi( $content );                  }
71    
72                    if ( $use->{stem} ) {
73                            my $stem = EPrints->stem( $content );
74                            warn "stem of '$content' didn't return anything\n" unless $stem;
75                            $content = $stem;
76                    }
77    
78                  if ( $use_score ) {  
79                          map { $body .= $content } 1 .. $parts->{$part}->[1];                  if ( $use->{score} ) {
80                            map { $body .= "$content " } 1 .. $parts->{$part}->[1];
81                  } else {                  } else {
82                          $body .= $content;                          $body .= "$content ";
83                  }                  }
84    
85                    warn ">>> $body <<<\n" if $debug;
86          }          }
87    
88          $indexer->index( $row->{id}, $body );          $indexer->index( $row->{id}, $body );

Legend:
Removed from v.14  
changed lines
  Added in v.17

  ViewVC Help
Powered by ViewVC 1.1.26