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 $questionWord = "";
36 return '' unless ($finalQMark);
37 return '' if (&IsParam("minVolunteerLength") == 0);
38 return '' if (length($query) < $param{'minVolunteerLength'});
40 ### TODO: this should be caught in Process.pl?
41 return '' unless ($talkok);
44 # dangerous; common preambles should be stripped before here
45 if ($query =~ /^forget /i or $query =~ /^no, /) {
46 return if (exists $bots{$nuh});
49 # convert to canonical reference form
53 push(@query, $query); # 1: push original.
55 $x = &normquery($query);
56 push(@query, $x) if ($x ne $query);
59 $x = &switchPerson($query);
60 push(@query, $x) if ($x ne $query);
63 $query =~ s/\s+at\s*(\?*)$/$1/; # where is x at?
64 $query =~ s/^explain\s*(\?*)/$1/i; # explain x
65 $query = " $query "; # side whitespaces.
67 my $qregex = join '|', keys %{$lang{'qWord'}};
69 # what's whats => what is; who'?s => who is, etc
70 $query =~ s/ ($qregex)\'?s / $1 is /i;
71 if ($query =~ s/\s+($qregex)\s+//i) { # check for question word
72 $questionWord = lc($1);
75 if ($questionWord eq "" and $finalQMark and $addressed) {
76 $questionWord = "where";
80 if ($query =~ s/[\!\.]$//) {
84 for (my$i=0; $i<scalar(@query); $i++) {
86 $result = &getReply($query);
87 next if (!defined $result or $result eq "");
89 # 'see also' factoid redirection support.
90 if ($result =~ /^see( also)? (.*?)\.?$/) {
91 my $newr = &getReply($2);
92 $result = $newr if ($newr ne "");
96 &DEBUG("Question: guessed factoid correctly ($i) => '$query'.");
102 ### TODO: Use &Forker(); move function to Freshmeat.pl.
103 if (&IsParam("freshmeatForFactoid")) {
104 &loadMyModule($myModules{'freshmeat'});
105 $result = &Freshmeat::showPackage($query);
106 return $result if (defined $result);
109 ### TODO: Use &Forker(); move function to Debian.pl
110 if (&IsParam("debianForFactoid")) {
111 &loadMyModule($myModules{'debian'});
112 $result = &Debian::DebianFind($query); # ???
113 ### TODO: debian module should tell, through shm, that it went
115 ### return $result if (defined $result);
118 if ($questionWord ne "" or $finalQMark) {
119 # if it has not been explicitly marked as a question
120 if ($addressed and $reply eq "") {
121 &status("notfound: <$who> ".join(' :: ', @query))
124 return '' unless (&IsParam("friendlyBots"));
126 foreach (split /\s+/, $param{'friendlyBots'}) {
127 &msg($_, ":INFOBOT:QUERY <$who> $query");