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

Contents of /EPrints/EPrints.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Fri Jun 29 09:08:58 2007 UTC (16 years, 10 months ago) by dpavlin
File size: 1033 byte(s)
EPrints indexer and searcher for Semantic-Engine
at http://www.hirank.com/semantic-indexing-project/index.html

1 # Dobrica Pavlinusic, <dpavlin@rot13.org> 06/28/07 23:28:21 CEST
2
3 package EPrints;
4
5 use Exporter 'import';
6 @EXPORT_OK = qw(_x);
7
8 use Encode qw/from_to decode_utf8 decode/;
9 use Data::Dump qw/dump/;
10
11 use strict;
12 use warnings;
13
14 my $debug = 0;
15
16 my $connect = "DBI:mysql:dbname=eprints";
17
18 my $dbh = DBI->connect($connect,"dpavlin","") || die $DBI::errstr;
19
20 sub dbh {
21 my $self = shift;
22 return $dbh;
23 }
24
25 my $id;
26
27 sub id {
28 my $self = shift;
29 if ( defined( $_[0] ) ) {
30 $id = $_[0];
31 warn "# id = $id\n" if $debug;
32 }
33 return $id;
34 }
35
36 sub lookup {
37 my $self = shift;
38 my $field = shift;
39
40 my $sql = qq{
41 SELECT $field
42 FROM archive_$field
43 WHERE eprintid = $id
44 };
45 warn "# sql: $sql\n" if $debug;
46 my @results = map { _x( $_->{$field} ) } @{ $dbh->selectall_arrayref($sql, { Slice => {} }) };
47
48 warn "# loookup( $field, $id ) = ", dump( @results ),$/ if $debug;
49 return join(" ", @results);
50 }
51
52 sub _x {
53 my $v = join(" ", @_);
54 decode_utf8( $v );
55 from_to( $v, 'utf-8', 'iso-8859-2' );
56 warn "_x($v)\n" if $debug;
57 return "$v ";
58 }
59
60 1;

  ViewVC Help
Powered by ViewVC 1.1.26