2 ### Question.pl: Kevin Lenzo (c) 1997
6 ## if ($query == query) {
14 if (&IsParam("useStrict")) { use strict; }
16 use vars qw($query $reply $finalQMark $nuh $result $talkok $who $nuh);
17 use vars qw(%bots %forked);
20 # my doesn't allow variables to be inherinted, local does.
21 # following is used in math()...
24 local $finalQMark = $query =~ s/\?+\s*$//;
25 $finalQMark += $query =~ s/\?\s*$//;
26 $query =~ s/^\s+|\s+$//g;
28 if (!defined $query or $query =~ /^\s*$/) {
29 &FIXME("doQ: query == NULL");
33 my $origQuery = $query;
34 my $questionWord = "";
37 return '' unless ($finalQMark);
38 return '' if (&IsParam("minVolunteerLength") == 0);
39 return '' if (length($query) < $param{'minVolunteerLength'});
41 ### TODO: this should be caught in Process.pl?
42 return '' unless ($talkok);
45 # dangerous; common preambles should be stripped before here
46 if ($query =~ /^forget /i or $query =~ /^no, /) {
47 return $noreply if (exists $bots{$nuh});
50 # convert to canonical reference form
54 push(@query, $query); # 1: push original.
56 $x = &normquery($query);
57 push(@query, $x) if ($x ne $query);
60 $x = &switchPerson($query);
61 push(@query, $x) if ($x ne $query);
64 $query =~ s/\s+at\s*(\?*)$/$1/; # where is x at?
65 $query =~ s/^explain\s*(\?*)/$1/i; # explain x
66 $query = " $query "; # side whitespaces.
68 my $qregex = join '|', keys %{$lang{'qWord'}};
70 # what's whats => what is; who'?s => who is, etc
71 $query =~ s/ ($qregex)\'?s / $1 is /i;
72 if ($query =~ s/\s+($qregex)\s+//i) { # check for question word
73 $questionWord = lc($1);
76 if ($questionWord eq "" and $finalQMark and $addressed) {
77 $questionWord = "where";
81 if ($query =~ s/[\!\.]$//) {
82 &DEBUG("Question: Pushing query without trailing symbols.");
86 for (my$i=0; $i<scalar(@query); $i++) {
88 $result = &getReply($query);
89 next if ($result eq "");
91 # 'see also' factoid redirection support.
92 if ($result =~ /^see( also)? (.*?)\.?$/) {
93 my $newr = &getReply($2);
94 $result = $newr if ($newr ne "");
98 &DEBUG("Question: guessed factoid correctly ($i) => '$query'.");
104 ### TODO: Use &Forker(); move function to Freshmeat.pl.
105 if (&IsParam("freshmeatForFactoid")) {
106 &loadMyModule($myModules{'freshmeat'});
107 $result = &Freshmeat::showPackage($query);
108 return $result unless ($result eq $noreply);
111 ### TODO: Use &Forker(); move function to Debian.pl
112 if (&IsParam("debianForFactoid")) {
113 &loadMyModule($myModules{'debian'});
114 $result = &Debian::DebianFind($query); # ???
115 ### TODO: debian module should tell, through shm, that it went
117 ### return $result unless ($result eq $noreply);
120 if ($questionWord ne "" or $finalQMark) {
121 # if it has not been explicitly marked as a question
122 if ($addressed and $reply eq "") {
123 if ($origQuery eq $query) {
124 &status("notfound: <$who> $origQuery");
126 &status("notfound: <$who> $origQuery :: $query");
129 return '' unless (&IsParam("friendlyBots"));
131 foreach (split /\s+/, $param{'friendlyBots'}) {
132 &msg($_, ":INFOBOT:QUERY <$who> $query");