--- trunk/html/swish.cgi 2003/04/30 12:40:09 32
+++ trunk/html/swish.cgi 2003/06/01 12:13:36 41
@@ -31,15 +31,21 @@
return $out;
}
-my $spelling_alt;
+my @spellings;
# FIX: doesn't work very well
if ($config->{findaffix}) {
- $spelling_alt = new Lingua::Spelling::Alternative;
- $spelling_alt->load_findaffix(x($config->{findaffix}));
+ foreach my $findaffix (split(/[, ]+/,x($config->{findaffix}))) {
+ my $spelling_alt = new Lingua::Spelling::Alternative;
+ $spelling_alt->load_findaffix($findaffix);
+ push @spellings,$spelling_alt;
+ }
}
if ($config->{affix}) {
- $spelling_alt = new Lingua::Spelling::Alternative;
- $spelling_alt->load_affix(x($config->{affix}));
+ foreach my $affix (split(/[, ]+/,x($config->{affix}))) {
+ my $spelling_alt = new Lingua::Spelling::Alternative;
+ $spelling_alt->load_affix($affix);
+ push @spellings,$spelling_alt;
+ }
}
my $hits=0;
@@ -54,6 +60,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 +79,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});
@@ -92,22 +100,32 @@
$search =~ s/^\s+//;
$search =~ s/\s+$//;
+ my %words;
+
foreach (split(/\s+/,$search)) {
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 +138,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 +147,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}));
}
@@ -160,7 +178,7 @@
$hits = $sh->query($s);
- if ($hits > 0) {
+ if ($hits && $hits > 0) {
print p,hr;
printf (x($config->{text}->{hits}),$hits,param('max_hits') || $max_hits,$s);
} else {