/[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

Annotation of /EPrints/index.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (hide annotations)
Fri Jun 29 14:53:14 2007 UTC (16 years, 9 months ago) by dpavlin
File MIME type: text/plain
File size: 1459 byte(s)
Use and enable searching of combination slogovi/stemming
1 dpavlin 1 #!/usr/bin/perl -w
2    
3     use strict;
4     use Semantic::API;
5     use Data::Dump qw/dump/;
6     use EPrints qw/_x/;
7     use lib '/home/dpavlin/stem-hr/';
8     use StemHR;
9    
10     my $debug = shift @ARGV;
11    
12     my $dbh = EPrints->dbh;
13     my $sth = $dbh->prepare(qq{
14     SELECT
15     archive_title.eprintid as id,
16     title
17     FROM archive_title
18     }) || die $dbh->errstr();
19     $sth->execute() || die $sth->errstr();
20    
21     my $indexer = Semantic::API::Index->new(
22     storage => 'sqlite',
23     database => 'eprints.db',
24     collection => 'EPrints'
25     );
26    
27    
28     $indexer->add_word_filters( minimum_length => 3,
29     too_many_numbers => 10,
30     maximum_word_length => 15 );
31    
32     # use this encoding for any incoming text
33 dpavlin 8 $indexer->set_default_encoding( "iso-8859-2" );
34 dpavlin 1
35     my $total = 0;
36    
37     while (my $row = $sth->fetchrow_hashref ) {
38     EPrints->id( $row->{id} );
39     my ( $title, $keywords, $abstract ) = (
40     _x( $row->{title} ),
41     EPrints->lookup( 'keywords' ),
42     EPrints->lookup( 'abstract' )
43     );
44     my @body = split( /\W*\s+\W*/, "$title $title $title $keywords $keywords $abstract" );
45 dpavlin 8 my $body = '';
46 dpavlin 1 foreach my $word ( @body ) {
47 dpavlin 8 $body .= StemHR->stem( $word ) . ' ';
48 dpavlin 1 }
49    
50 dpavlin 8 $body .= EPrints::slogovi( "$title $keywords $abstract" );
51    
52 dpavlin 1 warn "body: $body\n" if $debug;
53    
54     $indexer->index( $row->{id}, join(" ", @body, $body ) );
55     $total++;
56     print STDERR _x( $row->{id}, " ", $row->{title} ), "\n";
57     }
58    
59    
60     print STDERR "\nNow adding $total items to the database...";
61     $indexer->finish();
62     print STDERR "done!\n";
63    

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26