--- trunk/html/swish.cgi 2003/05/20 20:10:16 35
+++ trunk/html/swish.cgi 2003/06/01 11:41:39 39
@@ -31,15 +31,17 @@
return $out;
}
-my $spelling_alt;
+my @spellings;
# FIX: doesn't work very well
if ($config->{findaffix}) {
- $spelling_alt = new Lingua::Spelling::Alternative;
+ my $spelling_alt = new Lingua::Spelling::Alternative;
$spelling_alt->load_findaffix(x($config->{findaffix}));
+ push @spellings,$spelling_alt;
}
if ($config->{affix}) {
- $spelling_alt = new Lingua::Spelling::Alternative;
+ my $spelling_alt = new Lingua::Spelling::Alternative;
$spelling_alt->load_affix(x($config->{affix}));
+ push @spellings,$spelling_alt;
}
my $hits=0;
@@ -54,6 +56,8 @@
my %path_label;
my @path_name;
foreach (@{$config->{paths}->{path}}) {
+
+print STDERR "##: $_->{limit}",x($_->{content}),"\n";
push @path_name,x($_->{limit});
$path_label{$_->{limit}} = x($_->{content});
}
@@ -71,7 +75,7 @@
print x($config->{text}->{documents});
print textfield('search');
print submit(-value=> x($config->{text}->{submit}));
-print br,checkbox(-name=>'no_affix', -checked=>0, -label=>x($config->{text}->{no_spell})) if ($spelling_alt);
+print br,checkbox(-name=>'no_affix', -checked=>0, -label=>x($config->{text}->{no_spell})) if (@spellings);
print checkbox(-name=>'no_properties', -checked=>0, -label=>($config->{text}->{no_properties})) if (@properties);
if (@path_name) {
print br,x($config->{text}->{limit});
@@ -96,18 +100,26 @@
if (m/^([+-])(\S+)/) {
$s.= ($s) ? "and " : "";
$s.="not " if ($1 eq "-");
- if ($spelling_alt && !param('no_affix')) {
+ if (@spellings && !param('no_affix')) {
my $w = $2; $w =~ s/[\*\s]+//g;
$w =~ s/^(['"]*)([^'"]+)(['"]*)/$2/;
- $s.="$1(".join("* or ",$spelling_alt->alternatives($w))."*)$3 ";
+ my $or="";
+ foreach my $spelling_alt (@spellings) {
+ $s.="$or$1(".join("* or ",$spelling_alt->alternatives($w))."*)$3 ";
+ $or = "or ";
+ }
} else {
$s.="$2* ";
}
} else {
- if ($spelling_alt && !param('no_affix')) {
+ if (@spellings && !param('no_affix')) {
my $w = $_; $w =~ s/[\*\s]+//g;
#$s.="(".join("* or ",$spelling_alt->alternatives($w))."*) ";
- $s.="(".join("* or ",$spelling_alt->alternatives($w))."*) ";
+ my $or="";
+ foreach my $spelling_alt (@spellings) {
+ $s.="$or(".join("* or ",$spelling_alt->alternatives($w))."*) ";
+ $or = "or ";
+ }
} else {
$s.="$_* ";
}
@@ -120,7 +132,7 @@
$s=~s/\*\*+/*/g;
# limit to some path
- $s = "swishdocpath=(\"$path\") and $s" if ($path);
+ $s = "swishdocpath=(\"*$path*\") and $s" if ($path);
my %params; # optional parametars for swish
@@ -129,7 +141,7 @@
if (@properties) {
$hit_fmt = x($config->{hit}) if (! param('no_properties'));
- $params{properties} = \@properties if (@properties);
+ $params{properties} = \@properties;
} else {
$hit_fmt = x($config->{hit}) if (x($config->{hit}));
}