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