/[mws]/trunk/lib/MWS/SWISH.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/MWS/SWISH.pm

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

revision 24 by dpavlin, Sat May 8 14:27:54 2004 UTC revision 27 by dpavlin, Sat May 8 20:34:26 2004 UTC
# Line 10  use strict; Line 10  use strict;
10  use SWISH::API;  use SWISH::API;
11  use Text::Iconv;  use Text::Iconv;
12  use Data::Dumper;  use Data::Dumper;
13    use File::Temp qw/ :mktemp /;
14    
15  my $iso2utf = Text::Iconv->new('ISO-8859-2','UTF-8');  my $iso2utf = Text::Iconv->new('ISO-8859-2','UTF-8');
16  my $utf2iso = Text::Iconv->new('UTF-8','ISO-8859-2');  my $utf2iso = Text::Iconv->new('UTF-8','ISO-8859-2');
# Line 21  sub open_index { Line 22  sub open_index {
22    
23          if (! $swish) {          if (! $swish) {
24    
25                  my $index_file = $self->{index_file} || croak "open_index needs index filename";                  my $index_file = $self->{index_dir}."/".$self->{config_name};
                 $index_file .= "/swish-e";  
26                  print STDERR "opening index '$index_file'\n";                  print STDERR "opening index '$index_file'\n";
27                  $swish = SWISH::API->new($index_file);                  $swish = SWISH::API->new($index_file);
28                  $swish->AbortLastError if $swish->Error;                  $swish->AbortLastError if $swish->Error;
# Line 119  sub search_index { Line 119  sub search_index {
119          return @res_ids;          return @res_ids;
120  }  }
121    
122    # this function can be null for indexes which doesn't need special
123    # setup before add_index is called. however, swish-e support will
124    # fork swish binary to create index at this point
125    sub create_index {
126            my $self = shift;
127    
128            my $index_prog = $0 || die "can't deduce my own name!";
129            my $config_file = $self->{config_file} || die "no self->config_file";
130            my $index_file = $self->{index_dir} || die "no self->index_dir";
131            $index_file .= "/";
132            $index_file .= $self->{config_name} || die "no self->config_name";
133    
134            my ($tmp_fh, $swish_config_file) = mkstemp("/tmp/swishXXXXX");
135    
136            print STDERR "creating swish-e configuration file $swish_config_file\n";
137    
138            my $swish_config = qq{
139    # swish-e config file
140    
141    IndexDir $index_prog
142    SwishProgParameters --recursive $config_file
143    
144    # input file definition
145    DefaultContents XML2
146    
147    # indexed metatags
148    MetaNames xml swishdocpath
149    
150    # stored metatags
151    PropertyNames from_phrase from_address
152    PropertyNames to_phrase to_address
153    PropertyNames cc_phrase cc_address
154    PropertyNames subject body
155    #PropertyNamesDate date
156    PropertyNamesNumeric date_utime
157    PropertyNames date
158    
159    #XMLClassAttributes type
160    UndefinedMetaTags auto
161    UndefinedXMLAttributes auto
162    
163    IndexFile $index_file
164    
165    # Croatian ISO-8859-2 characters to unaccented equivalents
166    TranslateCharacters ¹©ðÐèÈæƾ® ssddcccczz
167    
168    
169    # debug
170    ParserWarnLevel 3
171    IndexReport 1
172    
173    };
174    
175            print $tmp_fh $swish_config;
176            close($tmp_fh);
177    
178            exec "swish-e -S prog -c $swish_config_file" || die "can't fork swish with $swish_config_file";
179            exit 0;
180    
181    }
182    
183  sub add_index {  sub add_index {
184          my $self = shift;          my $self = shift;
185    

Legend:
Removed from v.24  
changed lines
  Added in v.27

  ViewVC Help
Powered by ViewVC 1.1.26