]> git.donarmstrong.com Git - infobot.git/blob - src/Factoids/Norm.pl
Initial revision
[infobot.git] / src / Factoids / Norm.pl
1 #
2 #   Norm.pl: Norm.
3 #    Author: Kevin Lenzo
4 #   Version: 1997
5 #
6
7 if (&IsParam("useStrict")) { use strict; }
8
9 sub normquery {
10         my ($in) = @_;
11
12         $in = " $in ";
13
14         # where blah is -> where is blah
15         $in =~ s/ (where|what|who)\s+(\S+)\s+(is|are) / $1 $3 $2 /i;
16
17         # where blah is -> where is blah
18         $in =~ s/ (where|what|who)\s+(.*)\s+(is|are) / $1 $3 $2 /i;
19
20         $in =~ s/^\s*(.*?)\s*/$1/;
21
22         $in =~ s/be tellin\'?g?/tell/i;
23         $in =~ s/ \'?bout/ about/i;
24
25         $in =~ s/,? any(hoo?w?|ways?)/ /ig;
26         $in =~ s/,?\s*(pretty )*please\??\s*$/\?/i;
27
28
29         # what country is ...
30         if ($in =~ 
31             s/wh(at|ich)\s+(add?res?s|country|place|net (suffix|domain))/wh$1 /ig) {
32             if ((length($in) == 2) && ($in !~ /^\./)) {
33                 $in = '.'.$in;
34             }
35             $in .= '?';
36         }
37
38         # profanity filters.  just delete it
39         $in =~ s/th(e|at|is) (((m(o|u)th(a|er) ?)?fuck(in\'?g?)?|hell|heck|(god-?)?damn?(ed)?) ?)+//ig;
40         $in =~ s/wtf/where/gi;
41         $in =~ s/this (.*) thingy?/ $1/gi;
42         $in =~ s/this thingy? (called )?//gi;
43         $in =~ s/ha(s|ve) (an?y?|some|ne) (idea|clue|guess|seen) /know /ig;
44         $in =~ s/does (any|ne|some) ?(1|one|body) know //ig;
45         $in =~ s/do you know //ig;
46         $in =~ s/can (you|u|((any|ne|some) ?(1|one|body)))( please)? tell (me|us|him|her)//ig;
47         $in =~ s/where (\S+) can \S+ (a|an|the)?//ig;
48         $in =~ s/(can|do) (i|you|one|we|he|she) (find|get)( this)?/is/i; # where can i find
49         $in =~ s/(i|one|we|he|she) can (find|get)/is/gi; # where i can find
50         $in =~ s/(the )?(address|url) (for|to) //i; # this should be more specific
51         $in =~ s/(where is )+/where is /ig;
52         $in =~ s/\s+/ /g;
53         $in =~ s/^\s+//;
54         if ($in =~ s/\s*[\/?!]*\?+\s*$//) {
55             $finalQMark = 1;
56         }
57
58         $in =~ s/\s+/ /g;
59         $in =~ s/^\s*(.*?)\s*$/$1/;
60
61         $in;
62 }
63
64 # for be-verbs
65 sub switchPerson {
66         my($in) = @_;
67
68         $in =~ s/(^|\W)\Q$who\Es\s+/$1${who}\'s /ig; # fix genitives
69         $in =~ s/(^|\W)\Q$who\Es$/$1${who}\'s/ig; # fix genitives
70         $in =~ s/(^|\W)\Q$who\E\'(\s|$)/$1${who}\'s$2/ig; # fix genitives
71         $in =~ s/(^|\s)i\'m(\W|$)/$1$who is$2/ig;
72         $in =~ s/(^|\s)i\'ve(\W|$)/$1$who has$2/ig;
73         $in =~ s/(^|\s)i have(\W|$)/$1$who has$2/ig;
74         $in =~ s/(^|\s)i haven\'?t(\W|$)/$1$who has not$2/ig;
75         $in =~ s/(^|\s)i(\W|$)/$1$who$2/ig;
76         $in =~ s/ am\b/ is/i;
77         $in =~ s/\bam /is/i;
78         $in =~ s/(^|\s)(me|myself)(\W|$)/$1$who$3/ig;
79         $in =~ s/(^|\s)my(\W|$)/$1${who}\'s$2/ig; # turn 'my' into name's
80         $in =~ s/(^|\W)you\'?re(\W|$)/$1you are$2/ig;
81
82         if ($addressed) {
83                 $in =~ s/yourself/$param{'ircNick'}/i;
84                 $in =~ s/(^|\W)are you(\W|$)/$1is $param{'ircNick'}$2/ig;
85                 $in =~ s/(^|\W)you are(\W|$)/$1$param{'ircNick'} is$2/ig;
86                 $in =~ s/(^|\W)you(\W|$)/$1$param{'ircNick'}$2/ig;
87                 $in =~ s/(^|\W)your(\W|$)/$1$param{'ircNick'}\'s$2/ig;
88         }
89
90         $in;
91 }
92
93 # ---
94
95 1;