/[Search-Estraier]/trunk/lib/Search/Estraier.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 /trunk/lib/Search/Estraier.pm

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

revision 111 by dpavlin, Tue Feb 21 15:41:57 2006 UTC revision 184 by dpavlin, Sat Nov 4 13:10:29 2006 UTC
# Line 4  use 5.008; Line 4  use 5.008;
4  use strict;  use strict;
5  use warnings;  use warnings;
6    
7  our $VERSION = '0.04_3';  our $VERSION = '0.08_1';
8    
9  =head1 NAME  =head1 NAME
10    
# Line 20  Search::Estraier - pure perl module to u Line 20  Search::Estraier - pure perl module to u
20          my $node = new Search::Estraier::Node(          my $node = new Search::Estraier::Node(
21                  url => 'http://localhost:1978/node/test',                  url => 'http://localhost:1978/node/test',
22                  user => 'admin',                  user => 'admin',
23                  passwd => 'admin'                  passwd => 'admin',
24                    create => 1,
25                    label => 'Label for node',
26                    croak_on_error => 1,
27          );          );
28    
29          # create document          # create document
# Line 117  our @ISA = qw/Search::Estraier/; Line 120  our @ISA = qw/Search::Estraier/;
120    
121  =head1 Search::Estraier::Document  =head1 Search::Estraier::Document
122    
123  This class implements Document which is collection of attributes  This class implements Document which is single item in Hyper Estraier.
124  (key=value), vectors (also key value) display text and hidden text.  
125    It's is collection of:
126    
127    =over 4
128    
129    =item attributes
130    
131    C<< 'key' => 'value' >> pairs which can later be used for filtering of results
132    
133    You can add common filters to C<attrindex> in estmaster's C<_conf>
134    file for better performance. See C<attrindex> in
135    L<Hyper Estraier P2P Guide|http://hyperestraier.sourceforge.net/nguide-en.html>.
136    
137    =item vectors
138    
139    also C<< 'key' => 'value' >> pairs
140    
141    =item display text
142    
143    Text which will be used to create searchable corpus of your index and
144    included in snippet output.
145    
146    =item hidden text
147    
148    Text which will be searchable, but will not be included in snippet.
149    
150    =back
151    
152  =head2 new  =head2 new
153    
# Line 154  sub new { Line 182  sub new {
182    
183                          if ($line =~ m/^%VECTOR\t(.+)$/) {                          if ($line =~ m/^%VECTOR\t(.+)$/) {
184                                  my @fields = split(/\t/, $1);                                  my @fields = split(/\t/, $1);
185                                  for my $i ( 0 .. ($#fields - 1) ) {                                  if ($#fields % 2 == 1) {
186                                          $self->{kwords}->{ $fields[ $i ] } = $fields[ $i + 1 ];                                          $self->{kwords} = { @fields };
187                                          $i++;                                  } else {
188                                            warn "can't decode $line\n";
189                                  }                                  }
190                                  next;                                  next;
191                            } elsif ($line =~ m/^%SCORE\t(.+)$/) {
192                                $self->{score} = $1;
193                                next;
194                          } elsif ($line =~ m/^%/) {                          } elsif ($line =~ m/^%/) {
195                                  # What is this? comment?                                  # What is this? comment?
196                                  #warn "$line\n";                                  #warn "$line\n";
# Line 240  sub add_hidden_text { Line 272  sub add_hidden_text {
272          push @{ $self->{htexts} }, $self->_s($text);          push @{ $self->{htexts} }, $self->_s($text);
273  }  }
274    
275    =head2 add_vectors
276    
277    Add a vectors
278    
279      $doc->add_vector(
280            'vector_name' => 42,
281            'another' => 12345,
282      );
283    
284    =cut
285    
286    sub add_vectors {
287            my $self = shift;
288            return unless (@_);
289    
290            # this is ugly, but works
291            die "add_vector needs HASH as argument" unless ($#_ % 2 == 1);
292    
293            $self->{kwords} = {@_};
294    }
295    
296    =head2 set_score
297    
298    Set the substitute score
299    
300      $doc->set_score(12345);
301    
302    =cut
303    
304    sub set_score {
305        my $self = shift;
306        my $score = shift;
307        return unless (defined($score));
308        $self->{score} = $score;
309    }
310    
311    =head2 score
312    
313    Get the substitute score
314    
315    =cut
316    
317    sub score {
318        my $self = shift;
319        return -1 unless (defined($self->{score}));
320        return $self->{score};
321    }
322    
323  =head2 id  =head2 id
324    
# Line 334  sub dump_draft { Line 413  sub dump_draft {
413          }          }
414    
415          if ($self->{kwords}) {          if ($self->{kwords}) {
416                  $draft .= '%%VECTOR';                  $draft .= '%VECTOR';
417                  while (my ($key, $value) = each %{ $self->{kwords} }) {                  while (my ($key, $value) = each %{ $self->{kwords} }) {
418                          $draft .= "\t$key\t$value";                          $draft .= "\t$key\t$value";
419                  }                  }
420                  $draft .= "\n";                  $draft .= "\n";
421          }          }
422    
423            if (defined($self->{score}) && $self->{score} >= 0) {
424                $draft .= "%SCORE\t" . $self->{score} . "\n";
425            }
426    
427          $draft .= "\n";          $draft .= "\n";
428    
429          $draft .= join("\n", @{ $self->{dtexts} }) . "\n" if ($self->{dtexts});          $draft .= join("\n", @{ $self->{dtexts} }) . "\n" if ($self->{dtexts});
430          $draft .= "\t" . join("\n\t", @{ $self->{htexts} }) . "\n" if ($self->{htexts});          $draft .= "\t" . join("\n\t", @{ $self->{htexts} }) . "\n" if ($self->{htexts});
431    
432            printf("[%s]\n", $draft);
433    
434          return $draft;          return $draft;
435  }  }
436    
# Line 599  sub options { Line 684  sub options {
684  }  }
685    
686    
687    =head2 set_skip
688    
689    Set number of skipped documents from beginning of results
690    
691      $cond->set_skip(42);
692    
693    Similar to C<offset> in RDBMS.
694    
695    =cut
696    
697    sub set_skip {
698            my $self = shift;
699            $self->{skip} = shift;
700    }
701    
702    =head2 skip
703    
704    Return skip for this condition.
705    
706      print $cond->skip;
707    
708    =cut
709    
710    sub skip {
711            my $self = shift;
712            return $self->{skip};
713    }
714    
715    
716    =head2 set_distinct
717    
718      $cond->set_distinct('@author');
719    
720    =cut
721    
722    sub set_distinct {
723            my $self = shift;
724            $self->{distinct} = shift;
725    }
726    
727    =head2 distinct
728    
729    Return distinct attribute
730    
731      print $cond->distinct;
732    
733    =cut
734    
735    sub distinct {
736            my $self = shift;
737            return $self->{distinct};
738    }
739    
740    =head2 set_mask
741    
742    Filter out some links when searching.
743    
744    Argument array of link numbers, starting with 0 (current node).
745    
746      $cond->set_mask(qw/0 1 4/);
747    
748    =cut
749    
750    sub set_mask {
751            my $self = shift;
752            return unless (@_);
753            $self->{mask} = \@_;
754    }
755    
756    
757  package Search::Estraier::ResultDocument;  package Search::Estraier::ResultDocument;
758    
759  use Carp qw/croak/;  use Carp qw/croak/;
# Line 843  or in more verbose form Line 998  or in more verbose form
998    
999    my $node = new Search::HyperEstraier::Node(    my $node = new Search::HyperEstraier::Node(
1000          url => 'http://localhost:1978/node/test',          url => 'http://localhost:1978/node/test',
1001            user => 'admin',
1002            passwd => 'admin'
1003            create => 1,
1004            label => 'optional node label',
1005          debug => 1,          debug => 1,
1006          croak_on_error => 1          croak_on_error => 1
1007    );    );
# Line 855  with following arguments: Line 1014  with following arguments:
1014    
1015  URL to node  URL to node
1016    
1017    =item user
1018    
1019    specify username for node server authentication
1020    
1021    =item passwd
1022    
1023    password for authentication
1024    
1025    =item create
1026    
1027    create node if it doesn't exists
1028    
1029    =item label
1030    
1031    optional label for new node if C<create> is used
1032    
1033  =item debug  =item debug
1034    
1035  dumps a B<lot> of debugging output  dumps a B<lot> of debugging output
# Line 885  sub new { Line 1060  sub new {
1060          if ($#_ == 0) {          if ($#_ == 0) {
1061                  $self->{url} = shift;                  $self->{url} = shift;
1062          } else {          } else {
                 my $args = {@_};  
   
1063                  %$self = ( %$self, @_ );                  %$self = ( %$self, @_ );
1064    
1065                    $self->set_auth( $self->{user}, $self->{passwd} ) if ($self->{user});
1066    
1067                  warn "## Node debug on\n" if ($self->{debug});                  warn "## Node debug on\n" if ($self->{debug});
1068          }          }
1069    
# Line 898  sub new { Line 1073  sub new {
1073                  size => -1.0,                  size => -1.0,
1074          };          };
1075    
1076            if ($self->{create}) {
1077                    if (! eval { $self->name } || $@) {
1078                            my $name = $1 if ($self->{url} =~ m#/node/([^/]+)/*#);
1079                            croak "can't find node name in '$self->{url}'" unless ($name);
1080                            my $label = $self->{label} || $name;
1081                            $self->master(
1082                                    action => 'nodeadd',
1083                                    name => $name,
1084                                    label => $label,
1085                            ) || croak "can't create node $name ($label)";
1086                    }
1087            }
1088    
1089          $self ? return $self : return undef;          $self ? return $self : return undef;
1090  }  }
1091    
# Line 988  Add a document Line 1176  Add a document
1176    
1177    $node->put_doc( $document_draft ) or die "can't add document";    $node->put_doc( $document_draft ) or die "can't add document";
1178    
1179  Return true on success or false on failture.  Return true on success or false on failure.
1180    
1181  =cut  =cut
1182    
# Line 996  sub put_doc { Line 1184  sub put_doc {
1184          my $self = shift;          my $self = shift;
1185          my $doc = shift || return;          my $doc = shift || return;
1186          return unless ($self->{url} && $doc->isa('Search::Estraier::Document'));          return unless ($self->{url} && $doc->isa('Search::Estraier::Document'));
1187          $self->shuttle_url( $self->{url} . '/put_doc',          if ($self->shuttle_url( $self->{url} . '/put_doc',
1188                  'text/x-estraier-draft',                  'text/x-estraier-draft',
1189                  $doc->dump_draft,                  $doc->dump_draft,
1190                  undef                  undef
1191          ) == 200;          ) == 200) {
1192                    $self->_clear_info;
1193                    return 1;
1194            }
1195            return undef;
1196  }  }
1197    
1198    
# Line 1019  sub out_doc { Line 1211  sub out_doc {
1211          my $id = shift || return;          my $id = shift || return;
1212          return unless ($self->{url});          return unless ($self->{url});
1213          croak "id must be number, not '$id'" unless ($id =~ m/^\d+$/);          croak "id must be number, not '$id'" unless ($id =~ m/^\d+$/);
1214          $self->shuttle_url( $self->{url} . '/out_doc',          if ($self->shuttle_url( $self->{url} . '/out_doc',
1215                  'application/x-www-form-urlencoded',                  'application/x-www-form-urlencoded',
1216                  "id=$id",                  "id=$id",
1217                  undef                  undef
1218          ) == 200;          ) == 200) {
1219                    $self->_clear_info;
1220                    return 1;
1221            }
1222            return undef;
1223  }  }
1224    
1225    
# Line 1041  sub out_doc_by_uri { Line 1237  sub out_doc_by_uri {
1237          my $self = shift;          my $self = shift;
1238          my $uri = shift || return;          my $uri = shift || return;
1239          return unless ($self->{url});          return unless ($self->{url});
1240          $self->shuttle_url( $self->{url} . '/out_doc',          if ($self->shuttle_url( $self->{url} . '/out_doc',
1241                  'application/x-www-form-urlencoded',                  'application/x-www-form-urlencoded',
1242                  "uri=" . uri_escape($uri),                  "uri=" . uri_escape($uri),
1243                  undef                  undef
1244          ) == 200;          ) == 200) {
1245                    $self->_clear_info;
1246                    return 1;
1247            }
1248            return undef;
1249  }  }
1250    
1251    
# Line 1063  sub edit_doc { Line 1263  sub edit_doc {
1263          my $self = shift;          my $self = shift;
1264          my $doc = shift || return;          my $doc = shift || return;
1265          return unless ($self->{url} && $doc->isa('Search::Estraier::Document'));          return unless ($self->{url} && $doc->isa('Search::Estraier::Document'));
1266          $self->shuttle_url( $self->{url} . '/edit_doc',          if ($self->shuttle_url( $self->{url} . '/edit_doc',
1267                  'text/x-estraier-draft',                  'text/x-estraier-draft',
1268                  $doc->dump_draft,                  $doc->dump_draft,
1269                  undef                  undef
1270          ) == 200;          ) == 200) {
1271                    $self->_clear_info;
1272                    return 1;
1273            }
1274            return undef;
1275  }  }
1276    
1277    
# Line 1225  sub _fetch_doc { Line 1429  sub _fetch_doc {
1429          $path = '/etch_doc' if ($a->{etch});          $path = '/etch_doc' if ($a->{etch});
1430    
1431          if ($a->{id}) {          if ($a->{id}) {
1432                  croak "id must be numberm not '$a->{id}'" unless ($a->{id} =~ m/^\d+$/);                  croak "id must be number not '$a->{id}'" unless ($a->{id} =~ m/^\d+$/);
1433                  $arg = 'id=' . $a->{id};                  $arg = 'id=' . $a->{id};
1434          } elsif ($a->{uri}) {          } elsif ($a->{uri}) {
1435                  $arg = 'uri=' . uri_escape($a->{uri});                  $arg = 'uri=' . uri_escape($a->{uri});
# Line 1360  sub search { Line 1564  sub search {
1564          );          );
1565          return if ($rv != 200);          return if ($rv != 200);
1566    
1567          my (@docs, $hints);          my @records     = split /--------\[.*?\]--------(?::END)?\r?\n/, $resbody;
1568            my $hintsText   = splice @records, 0, 2; # starts with empty record
1569          my @lines = split(/\n/, $resbody);          my $hints               = { $hintsText =~ m/^(.*?)\t(.*?)$/gsm };
1570          return unless (@lines);  
1571            # process records
1572          my $border = $lines[0];          my $docs = [];
1573          my $isend = 0;          foreach my $record (@records)
1574          my $lnum = 1;          {
1575                    # split into keys and snippets
1576          while ( $lnum <= $#lines ) {                  my ($keys, $snippet) = $record =~ m/^(.*?)\n\n(.*?)$/s;
1577                  my $line = $lines[$lnum];  
1578                  $lnum++;                  # create document hash
1579                    my $doc                         = { $keys =~ m/^(.*?)=(.*?)$/gsm };
1580                  #warn "## $line\n";                  $doc->{'@keywords'}     = $doc->{keywords};
1581                  if ($line && $line =~ m/^\Q$border\E(:END)*$/) {                  ($doc->{keywords})      = $keys =~ m/^%VECTOR\t(.*?)$/gm;
1582                          $isend = $1;                  $doc->{snippet}         = $snippet;
1583                          last;  
1584                  }                  push @$docs, new Search::Estraier::ResultDocument(
1585                            attrs           => $doc,
1586                  if ($line =~ /\t/) {                          uri             => $doc->{'@uri'},
1587                          my ($k,$v) = split(/\t/, $line, 2);                          snippet         => $snippet,
1588                          $hints->{$k} = $v;                          keywords        => $doc->{'keywords'},
1589                  }                  );
         }  
   
         my $snum = $lnum;  
   
         while( ! $isend && $lnum <= $#lines ) {  
                 my $line = $lines[$lnum];  
                 #warn "# $lnum: $line\n";  
                 $lnum++;  
   
                 if ($line && $line =~ m/^\Q$border\E/) {  
                         if ($lnum > $snum) {  
                                 my $rdattrs;  
                                 my $rdvector;  
                                 my $rdsnippet;  
                                   
                                 my $rlnum = $snum;  
                                 while ($rlnum < $lnum - 1 ) {  
                                         #my $rdline = $self->_s($lines[$rlnum]);  
                                         my $rdline = $lines[$rlnum];  
                                         $rlnum++;  
                                         last unless ($rdline);  
                                         if ($rdline =~ /^%/) {  
                                                 $rdvector = $1 if ($rdline =~ /^%VECTOR\t(.+)$/);  
                                         } elsif($rdline =~ /=/) {  
                                                 $rdattrs->{$1} = $2 if ($rdline =~ /^(.+)=(.+)$/);  
                                         } else {  
                                                 confess "invalid format of response";  
                                         }  
                                 }  
                                 while($rlnum < $lnum - 1) {  
                                         my $rdline = $lines[$rlnum];  
                                         $rlnum++;  
                                         $rdsnippet .= "$rdline\n";  
                                 }  
                                 #warn Dumper($rdvector, $rdattrs, $rdsnippet);  
                                 if (my $rduri = $rdattrs->{'@uri'}) {  
                                         push @docs, new Search::Estraier::ResultDocument(  
                                                 uri => $rduri,  
                                                 attrs => $rdattrs,  
                                                 snippet => $rdsnippet,  
                                                 keywords => $rdvector,  
                                         );  
                                 }  
                         }  
                         $snum = $lnum;  
                         #warn "### $line\n";  
                         $isend = 1 if ($line =~ /:END$/);  
                 }  
   
         }  
   
         if (! $isend) {  
                 warn "received result doesn't have :END\n$resbody";  
                 return;  
1590          }          }
1591    
1592          #warn Dumper(\@docs, $hints);          return new Search::Estraier::NodeResult( docs => $docs, hints => $hints );
   
         return new Search::Estraier::NodeResult( docs => \@docs, hints => $hints );  
1593  }  }
1594    
1595    
# Line 1490  sub cond_to_query { Line 1638  sub cond_to_query {
1638          push @args, 'wwidth=' . $self->{wwidth};          push @args, 'wwidth=' . $self->{wwidth};
1639          push @args, 'hwidth=' . $self->{hwidth};          push @args, 'hwidth=' . $self->{hwidth};
1640          push @args, 'awidth=' . $self->{awidth};          push @args, 'awidth=' . $self->{awidth};
1641            push @args, 'skip=' . $cond->{skip} if ($cond->{skip});
1642    
1643            if (my $distinct = $cond->distinct) {
1644                    push @args, 'distinct=' . uri_escape($distinct);
1645            }
1646    
1647            if ($cond->{mask}) {
1648                    my $mask = 0;
1649                    map { $mask += ( 2 ** $_ ) } @{ $cond->{mask} };
1650    
1651                    push @args, 'mask=' . $mask if ($mask);
1652            }
1653    
1654          return join('&', @args);          return join('&', @args);
1655  }  }
# Line 1636  sub set_user { Line 1796  sub set_user {
1796          croak "mode must be number, not '$mode'" unless ($mode =~ m/^\d+$/);          croak "mode must be number, not '$mode'" unless ($mode =~ m/^\d+$/);
1797    
1798          $self->shuttle_url( $self->{url} . '/_set_user',          $self->shuttle_url( $self->{url} . '/_set_user',
1799                  'text/plain',                  'application/x-www-form-urlencoded',
1800                  'name=' . uri_escape($name) . '&mode=' . $mode,                  'name=' . uri_escape($name) . '&mode=' . $mode,
1801                  undef                  undef
1802          ) == 200;          ) == 200;
# Line 1669  sub set_link { Line 1829  sub set_link {
1829                  undef                  undef
1830          ) == 200) {          ) == 200) {
1831                  # refresh node info after adding link                  # refresh node info after adding link
1832                  $self->_set_info;                  $self->_clear_info;
1833                  return 1;                  return 1;
1834          }          }
1835            return undef;
1836  }  }
1837    
1838  =head2 admins  =head2 admins
# Line 1716  sub links { Line 1877  sub links {
1877          return $self->{inform}->{links};          return $self->{inform}->{links};
1878  }  }
1879    
1880    =head2 cacheusage
1881    
1882    Return cache usage for a node
1883    
1884      my $cache = $node->cacheusage;
1885    
1886    =cut
1887    
1888    sub cacheusage {
1889            my $self = shift;
1890    
1891            return unless ($self->{url});
1892    
1893            my $resbody;
1894            my $rv = $self->shuttle_url( $self->{url} . '/cacheusage',
1895                    'text/plain',
1896                    undef,
1897                    \$resbody,
1898            );
1899    
1900            return if ($rv != 200 || !$resbody);
1901    
1902            return $resbody;
1903    }
1904    
1905    =head2 master
1906    
1907    Set actions on Hyper Estraier node master (C<estmaster> process)
1908    
1909      $node->master(
1910            action => 'sync'
1911      );
1912    
1913    All available actions are documented in
1914    L<http://hyperestraier.sourceforge.net/nguide-en.html#protocol>
1915    
1916    =cut
1917    
1918    my $estmaster_rest = {
1919            shutdown => {
1920                    status => 202,
1921            },
1922            sync => {
1923                    status => 202,
1924            },
1925            backup => {
1926                    status => 202,
1927            },
1928            userlist => {
1929                    status => 200,
1930                    returns => [ qw/name passwd flags fname misc/ ],
1931            },
1932            useradd => {
1933                    required => [ qw/name passwd flags/ ],
1934                    optional => [ qw/fname misc/ ],
1935                    status => 200,
1936            },
1937            userdel => {
1938                    required => [ qw/name/ ],
1939                    status => 200,
1940            },
1941            nodelist => {
1942                    status => 200,
1943                    returns => [ qw/name label doc_num word_num size/ ],
1944            },
1945            nodeadd => {
1946                    required => [ qw/name/ ],
1947                    optional => [ qw/label/ ],
1948                    status => 200,
1949            },
1950            nodedel => {
1951                    required => [ qw/name/ ],
1952                    status => 200,
1953            },
1954            nodeclr => {
1955                    required => [ qw/name/ ],
1956                    status => 200,
1957            },
1958            nodertt => {
1959                    status => 200,  
1960            },
1961    };
1962    
1963    sub master {
1964            my $self = shift;
1965    
1966            my $args = {@_};
1967    
1968            # have action?
1969            my $action = $args->{action} || croak "need action, available: ",
1970                    join(", ",keys %{ $estmaster_rest });
1971    
1972            # check if action is valid
1973            my $rest = $estmaster_rest->{$action};
1974            croak "action '$action' is not supported, available actions: ",
1975                    join(", ",keys %{ $estmaster_rest }) unless ($rest);
1976    
1977            croak "BUG: action '$action' needs return status" unless ($rest->{status});
1978    
1979            my @args;
1980    
1981            if ($rest->{required} || $rest->{optional}) {
1982    
1983                    map {
1984                            croak "need parametar '$_' for action '$action'" unless ($args->{$_});
1985                            push @args, $_ . '=' . uri_escape( $args->{$_} );
1986                    } ( @{ $rest->{required} } );
1987    
1988                    map {
1989                            push @args, $_ . '=' . uri_escape( $args->{$_} ) if ($args->{$_});
1990                    } ( @{ $rest->{optional} } );
1991    
1992            }
1993    
1994            my $uri = new URI( $self->{url} );
1995    
1996            my $resbody;
1997    
1998            my $status = $self->shuttle_url(
1999                    'http://' . $uri->host_port . '/master?action=' . $action ,
2000                    'application/x-www-form-urlencoded',
2001                    join('&', @args),
2002                    \$resbody,
2003                    1,
2004            ) or confess "shuttle_url failed";
2005    
2006            if ($status == $rest->{status}) {
2007    
2008                    # refresh node info after sync
2009                    $self->_clear_info if ($action eq 'sync' || $action =~ m/^node(?:add|del|clr)$/);
2010    
2011                    if ($rest->{returns} && wantarray) {
2012    
2013                            my @results;
2014                            my $fields = $#{$rest->{returns}};
2015    
2016                            foreach my $line ( split(/[\r\n]/,$resbody) ) {
2017                                    my @e = split(/\t/, $line, $fields + 1);
2018                                    my $row;
2019                                    foreach my $i ( 0 .. $fields) {
2020                                            $row->{ $rest->{returns}->[$i] } = $e[ $i ];
2021                                    }
2022                                    push @results, $row;
2023                            }
2024    
2025                            return @results;
2026    
2027                    } elsif ($resbody) {
2028                            chomp $resbody;
2029                            return $resbody;
2030                    } else {
2031                            return 0E0;
2032                    }
2033            }
2034    
2035            carp "expected status $rest->{status}, but got $status";
2036            return undef;
2037    }
2038    
2039  =head1 PRIVATE METHODS  =head1 PRIVATE METHODS
2040    
# Line 1746  sub _set_info { Line 2065  sub _set_info {
2065    
2066          my @lines = split(/[\r\n]/,$resbody);          my @lines = split(/[\r\n]/,$resbody);
2067    
2068          $self->{inform} = {};          $self->_clear_info;
2069    
2070          ( $self->{inform}->{name}, $self->{inform}->{label}, $self->{inform}->{dnum},          ( $self->{inform}->{name}, $self->{inform}->{label}, $self->{inform}->{dnum},
2071                  $self->{inform}->{wnum}, $self->{inform}->{size} ) = split(/\t/, shift @lines, 5);                  $self->{inform}->{wnum}, $self->{inform}->{size} ) = split(/\t/, shift @lines, 5);
# Line 1771  sub _set_info { Line 2090  sub _set_info {
2090    
2091  }  }
2092    
2093    =head2 _clear_info
2094    
2095    Clear information for node
2096    
2097      $node->_clear_info;
2098    
2099    On next call to C<name>, C<label>, C<doc_num>, C<word_num> or C<size> node
2100    info will be fetch again from Hyper Estraier.
2101    
2102    =cut
2103    sub _clear_info {
2104            my $self = shift;
2105            $self->{inform} = {
2106                    dnum => -1,
2107                    wnum => -1,
2108                    size => -1.0,
2109            };
2110    }
2111    
2112  ###  ###
2113    
2114  =head1 EXPORT  =head1 EXPORT
# Line 1783  L<http://hyperestraier.sourceforge.net/> Line 2121  L<http://hyperestraier.sourceforge.net/>
2121    
2122  Hyper Estraier Ruby interface on which this module is based.  Hyper Estraier Ruby interface on which this module is based.
2123    
2124    Hyper Estraier now also has pure-perl binding included in distribution. It's
2125    a faster way to access databases directly if you are not running
2126    C<estmaster> P2P server.
2127    
2128  =head1 AUTHOR  =head1 AUTHOR
2129    
2130  Dobrica Pavlinusic, E<lt>dpavlin@rot13.orgE<gt>  Dobrica Pavlinusic, E<lt>dpavlin@rot13.orgE<gt>
2131    
2132    Robert Klep E<lt>robert@klep.nameE<gt> contributed refactored search code
2133    
2134  =head1 COPYRIGHT AND LICENSE  =head1 COPYRIGHT AND LICENSE
2135    

Legend:
Removed from v.111  
changed lines
  Added in v.184

  ViewVC Help
Powered by ViewVC 1.1.26