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

Diff of /EPrints/EPrints.pm

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

revision 3 by dpavlin, Fri Jun 29 09:21:11 2007 UTC revision 12 by dpavlin, Fri Jun 29 17:03:54 2007 UTC
# Line 3  Line 3 
3  package EPrints;  package EPrints;
4    
5  use Exporter 'import';  use Exporter 'import';
6  @EXPORT_OK = qw(_x);  @EXPORT_OK = qw(_x slogovi);
7    
8  use Encode qw/from_to decode_utf8 decode/;  use Encode qw/from_to decode_utf8 decode/;
9  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
# Line 37  sub id { Line 37  sub id {
37  sub lookup {  sub lookup {
38          my $self = shift;          my $self = shift;
39          my $field = shift;          my $field = shift;
40            my $table = shift;
41            my $where = '';
42    
43            if ( ! $table ) {
44                    $table = "archive_$field";
45                    $where = " and lang = 'hr'";
46            }
47    
48          my $sql = qq{          my $sql = qq{
49          SELECT $field          SELECT $field
50          FROM archive_$field          FROM $table
51          WHERE eprintid = $id          WHERE eprintid = $id $where
52          };          };
53          warn "# sql: $sql\n" if $debug;          warn "# sql: $sql\n" if $debug;
54          my @results = map { _x( $_->{$field} ) } @{ $dbh->selectall_arrayref($sql, { Slice => {} }) };          my @results = map { _x( $_->{$field} ) } @{ $dbh->selectall_arrayref($sql, { Slice => {} }) };
# Line 50  sub lookup { Line 57  sub lookup {
57          return join("   ", @results);          return join("   ", @results);
58  }  }
59    
60    sub fulltext {
61            my $self = shift;
62            return split(/;/, EPrints->lookup( 'fileinfo', 'archive' ));
63    }
64    
65  sub _x {  sub _x {
66          my $v = join(" ", @_);          my $v = join(" ", @_);
67          decode_utf8( $v );          decode_utf8( $v );
# Line 58  sub _x { Line 70  sub _x {
70          return "$v ";          return "$v ";
71  }  }
72    
73    sub slogovi {
74            my $text = shift;
75    
76            my $count = 2;
77            my $out = '';
78    
79            foreach my $w ( split(/\W*\s+\W*/, $text ) ) {
80                    warn "w: $w\n" if $debug;
81                    my @s;
82                    while ( $w =~ s/^([^aeiou]*[aeiou])//i ) {
83                            push @s, $1;
84                    }
85                    push @s, $w if $w;
86                    warn "slogovi = ", dump( @s ), $/ if $debug;
87                    foreach my $p ( 0 .. ( $#s - $count + 1 )  ) {
88                            map { $out .= $s[ $p + $_ ] } 0 .. $count - 1;
89                            $out .= ' ';
90                    }
91            }
92            warn "$out\n" if $debug;
93            return $out;
94    }
95    
96  1;  1;

Legend:
Removed from v.3  
changed lines
  Added in v.12

  ViewVC Help
Powered by ViewVC 1.1.26