local($reply) = "";
local $finalQMark = $query =~ s/\?+\s*$//;
$finalQMark += $query =~ s/\?\s*$//;
+ $query =~ s/^\s+|\s+$//g;
if (!defined $query or $query =~ /^\s*$/) {
&FIXME("doQ: query == NULL");
return '';
}
- my $origQuery = $query;
-
my $questionWord = "";
if (!$addressed) {
return '' unless ($finalQMark);
-
- if (&IsParam("minVolunteerLength") == 0 or
- length($query) < $param{'minVolunteerLength'})
- {
- return '';
- }
+ return '' if (&IsParam("minVolunteerLength") == 0);
+ return '' if (length($query) < $param{'minVolunteerLength'});
} else {
### TODO: this should be caught in Process.pl?
return '' unless ($talkok);
}
# convert to canonical reference form
- $query = &normquery($query);
- $query = &switchPerson($query);
+ my $x;
+ my @query;
+
+ push(@query, $query); # 1: push original.
+
+ $x = &normquery($query);
+ push(@query, $x) if ($x ne $query);
+ $query = $x;
+
+ $x = &switchPerson($query);
+ push(@query, $x) if ($x ne $query);
+ $query = $x;
$query =~ s/\s+at\s*(\?*)$/$1/; # where is x at?
$query =~ s/^explain\s*(\?*)/$1/i; # explain x
$questionWord = "where";
}
- $query =~ s/^\s+|\s+$//g;
-
# valid factoid.
- if (defined( $result = &getReply($query) )) {
+ if ($query =~ s/[\!\.]$//) {
+ &DEBUG("Question: Pushing query without trailing symbols.");
+ push(@query,$query);
+ }
+
+ for (my$i=0; $i<scalar(@query); $i++) {
+ $query = $query[$i];
+ $result = &getReply($query);
+ next if ($result eq "");
+
# 'see also' factoid redirection support.
if ($result =~ /^see( also)? (.*?)\.?$/) {
my $newr = &getReply($2);
$result = $newr if ($newr ne "");
}
- return $result if ($result ne "");
-
- ### TODO: Use &Forker(); move function to Freshmeat.pl.
- if (&IsParam("freshmeatForFactoid")) {
- &loadMyModule($myModules{'freshmeat'});
- $result = &Freshmeat::showPackage($query);
- return $result unless ($result eq $noreply);
+ if ($i != 0) {
+ &DEBUG("Question: guessed factoid correctly ($i) => '$query'.");
}
- &DEBUG("Question: hrm... result => '$result'.");
+ return $result;
+ }
+
+ ### TODO: Use &Forker(); move function to Freshmeat.pl.
+ if (&IsParam("freshmeatForFactoid")) {
+ &loadMyModule($myModules{'freshmeat'});
+ $result = &Freshmeat::showPackage($query);
+ return $result unless ($result eq $noreply);
+ }
+
+ ### TODO: Use &Forker(); move function to Debian.pl
+ if (&IsParam("debianForFactoid")) {
+ &loadMyModule($myModules{'debian'});
+ $result = &Debian::DebianFind($query); # ???
+ ### TODO: debian module should tell, through shm, that it went
+ ### ok or not.
+### return $result unless ($result eq $noreply);
}
if ($questionWord ne "" or $finalQMark) {
# if it has not been explicitly marked as a question
if ($addressed and $reply eq "") {
- if ($origQuery eq $query) {
- &status("notfound: <$who> $origQuery");
- } else {
- &status("notfound: <$who> $origQuery :: $query");
- }
+ &status("notfound: <$who> ".join(' :: ', @query));
return '' unless (&IsParam("friendlyBots"));