31 |
return $out; |
return $out; |
32 |
} |
} |
33 |
|
|
34 |
my $spelling_alt; |
my @spellings; |
35 |
# FIX: doesn't work very well |
# FIX: doesn't work very well |
36 |
if ($config->{findaffix}) { |
if ($config->{findaffix}) { |
37 |
$spelling_alt = new Lingua::Spelling::Alternative; |
my $spelling_alt = new Lingua::Spelling::Alternative; |
38 |
$spelling_alt->load_findaffix(x($config->{findaffix})); |
$spelling_alt->load_findaffix(x($config->{findaffix})); |
39 |
|
push @spellings,$spelling_alt; |
40 |
} |
} |
41 |
if ($config->{affix}) { |
if ($config->{affix}) { |
42 |
$spelling_alt = new Lingua::Spelling::Alternative; |
my $spelling_alt = new Lingua::Spelling::Alternative; |
43 |
$spelling_alt->load_affix(x($config->{affix})); |
$spelling_alt->load_affix(x($config->{affix})); |
44 |
|
push @spellings,$spelling_alt; |
45 |
} |
} |
46 |
|
|
47 |
my $hits=0; |
my $hits=0; |
56 |
my %path_label; |
my %path_label; |
57 |
my @path_name; |
my @path_name; |
58 |
foreach (@{$config->{paths}->{path}}) { |
foreach (@{$config->{paths}->{path}}) { |
59 |
|
|
60 |
|
print STDERR "##: $_->{limit}",x($_->{content}),"\n"; |
61 |
push @path_name,x($_->{limit}); |
push @path_name,x($_->{limit}); |
62 |
$path_label{$_->{limit}} = x($_->{content}); |
$path_label{$_->{limit}} = x($_->{content}); |
63 |
} |
} |
75 |
print x($config->{text}->{documents}); |
print x($config->{text}->{documents}); |
76 |
print textfield('search'); |
print textfield('search'); |
77 |
print submit(-value=> x($config->{text}->{submit})); |
print submit(-value=> x($config->{text}->{submit})); |
78 |
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); |
79 |
print checkbox(-name=>'no_properties', -checked=>0, -label=>($config->{text}->{no_properties})) if (@properties); |
print checkbox(-name=>'no_properties', -checked=>0, -label=>($config->{text}->{no_properties})) if (@properties); |
80 |
if (@path_name) { |
if (@path_name) { |
81 |
print br,x($config->{text}->{limit}); |
print br,x($config->{text}->{limit}); |
100 |
if (m/^([+-])(\S+)/) { |
if (m/^([+-])(\S+)/) { |
101 |
$s.= ($s) ? "and " : ""; |
$s.= ($s) ? "and " : ""; |
102 |
$s.="not " if ($1 eq "-"); |
$s.="not " if ($1 eq "-"); |
103 |
if ($spelling_alt && !param('no_affix')) { |
if (@spellings && !param('no_affix')) { |
104 |
my $w = $2; $w =~ s/[\*\s]+//g; |
my $w = $2; $w =~ s/[\*\s]+//g; |
105 |
$w =~ s/^(['"]*)([^'"]+)(['"]*)/$2/; |
$w =~ s/^(['"]*)([^'"]+)(['"]*)/$2/; |
106 |
$s.="$1(".join("* or ",$spelling_alt->alternatives($w))."*)$3 "; |
my $or=""; |
107 |
|
foreach my $spelling_alt (@spellings) { |
108 |
|
$s.="$or$1(".join("* or ",$spelling_alt->alternatives($w))."*)$3 "; |
109 |
|
$or = "or "; |
110 |
|
} |
111 |
} else { |
} else { |
112 |
$s.="$2* "; |
$s.="$2* "; |
113 |
} |
} |
114 |
} else { |
} else { |
115 |
if ($spelling_alt && !param('no_affix')) { |
if (@spellings && !param('no_affix')) { |
116 |
my $w = $_; $w =~ s/[\*\s]+//g; |
my $w = $_; $w =~ s/[\*\s]+//g; |
117 |
#$s.="(".join("* or ",$spelling_alt->alternatives($w))."*) "; |
#$s.="(".join("* or ",$spelling_alt->alternatives($w))."*) "; |
118 |
$s.="(".join("* or ",$spelling_alt->alternatives($w))."*) "; |
my $or=""; |
119 |
|
foreach my $spelling_alt (@spellings) { |
120 |
|
$s.="$or(".join("* or ",$spelling_alt->alternatives($w))."*) "; |
121 |
|
$or = "or "; |
122 |
|
} |
123 |
} else { |
} else { |
124 |
$s.="$_* "; |
$s.="$_* "; |
125 |
} |
} |
132 |
$s=~s/\*\*+/*/g; |
$s=~s/\*\*+/*/g; |
133 |
|
|
134 |
# limit to some path |
# limit to some path |
135 |
$s = "swishdocpath=(\"$path\") and $s" if ($path); |
$s = "swishdocpath=(\"*$path*\") and $s" if ($path); |
136 |
|
|
137 |
my %params; # optional parametars for swish |
my %params; # optional parametars for swish |
138 |
|
|
141 |
|
|
142 |
if (@properties) { |
if (@properties) { |
143 |
$hit_fmt = x($config->{hit}) if (! param('no_properties')); |
$hit_fmt = x($config->{hit}) if (! param('no_properties')); |
144 |
$params{properties} = \@properties if (@properties); |
$params{properties} = \@properties; |
145 |
} else { |
} else { |
146 |
$hit_fmt = x($config->{hit}) if (x($config->{hit})); |
$hit_fmt = x($config->{hit}) if (x($config->{hit})); |
147 |
} |
} |