10 |
use StemHR; |
use StemHR; |
11 |
|
|
12 |
my $debug = shift @ARGV; |
my $debug = shift @ARGV; |
13 |
|
my $use_score = 0; |
14 |
|
|
15 |
my $dbh = EPrints->dbh; |
my $dbh = EPrints->dbh; |
16 |
my $sth = $dbh->prepare(qq{ |
my $sth = $dbh->prepare(qq{ |
39 |
|
|
40 |
while (my $row = $sth->fetchrow_hashref ) { |
while (my $row = $sth->fetchrow_hashref ) { |
41 |
EPrints->id( $row->{id} ); |
EPrints->id( $row->{id} ); |
42 |
my ( $title, $keywords, $abstract ) = ( |
my $parts = { |
43 |
_x( $row->{title} ), |
title => [ _x( $row->{title} ), 4 ], |
44 |
EPrints->lookup( 'keywords' ), |
keywords => [ EPrints->lookup( 'keywords' ), 3 ], |
45 |
EPrints->lookup( 'abstract' ) |
abstract => [ EPrints->lookup( 'abstract' ), 2 ], |
46 |
); |
# content => [ EPrints->fulltext_content, 1 ], |
47 |
my @body = split( /\W*\s+\W*/, "$title $title $title $keywords $keywords $abstract" ); |
}; |
|
my $body = ''; |
|
|
foreach my $word ( @body ) { |
|
|
$body .= StemHR->stem( $word ) . ' '; |
|
|
} |
|
|
|
|
|
$body .= EPrints::slogovi( "$title $keywords $abstract" ); |
|
48 |
|
|
49 |
warn "body: $body\n" if $debug; |
my $body = ''; |
50 |
|
|
51 |
$body .= EPrints->fulltext_content; |
foreach my $part ( qw/title keywords abstract content/ ) { |
52 |
|
my $content = $parts->{$part}->[0]; |
53 |
|
next unless defined $content; |
54 |
|
|
55 |
|
# $content = StemHR->stem( $content ); |
56 |
|
$content = EPrints->slogovi( $content ); |
57 |
|
|
58 |
|
if ( $use_score ) { |
59 |
|
map { $body .= $content } 1 .. $parts->{$part}->[1]; |
60 |
|
} else { |
61 |
|
$body .= $content; |
62 |
|
} |
63 |
|
} |
64 |
|
|
65 |
$indexer->index( $row->{id}, join(" ", @body, $body ) ); |
$indexer->index( $row->{id}, $body ); |
66 |
$total++; |
$total++; |
67 |
print STDERR _x( $row->{id}, " ", $row->{title} ), "\n"; |
print STDERR "$total: ", $row->{id}, " ", _x( $row->{title} ), " - ", length($body), " bytes\n"; |
68 |
} |
} |
69 |
|
|
70 |
|
|