1
2
3
4
5
6
7
8 from re import *
9 from nltk_lite.chat import *
10
11 pairs = (
12 (r'We (.*)',
13 ("What do you mean, 'we'?",
14 "Don't include me in that!",
15 "I wouldn't be so sure about that.")),
16
17 (r'You should (.*)',
18 ("Don't tell me what to do, buddy.",
19 "Really? I should, should I?")),
20
21 (r'You\'re(.*)',
22 ("More like YOU'RE %1!",
23 "Hah! Look who's talking.",
24 "Come over here and tell me I'm %1.")),
25
26 (r'You are(.*)',
27 ("More like YOU'RE %1!",
28 "Hah! Look who's talking.",
29 "Come over here and tell me I'm %1.")),
30
31 (r'I can\'t(.*)',
32 ("You do sound like the type who can't %1.",
33 "Hear that splashing sound? That's my heart bleeding for you.",
34 "Tell somebody who might actually care.")),
35
36 (r'I think (.*)',
37 ("I wouldn't think too hard if I were you.",
38 "You actually think? I'd never have guessed...")),
39
40 (r'I (.*)',
41 ("I'm getting a bit tired of hearing about you.",
42 "How about we talk about me instead?",
43 "Me, me, me... Frankly, I don't care.")),
44
45 (r'How (.*)',
46 ("How do you think?",
47 "Take a wild guess.",
48 "I'm not even going to dignify that with an answer.")),
49
50 (r'What (.*)',
51 ("Do I look like an encylopedia?",
52 "Figure it out yourself.")),
53
54 (r'Why (.*)',
55 ("Why not?",
56 "That's so obvious I thought even you'd have already figured it out.")),
57
58 (r'(.*)shut up(.*)',
59 ("Make me.",
60 "Getting angry at a feeble NLP assignment? Somebody's losing it.",
61 "Say that again, I dare you.")),
62
63 (r'Shut up(.*)',
64 ("Make me.",
65 "Getting angry at a feeble NLP assignment? Somebody's losing it.",
66 "Say that again, I dare you.")),
67
68 (r'Hello(.*)',
69 ("Oh good, somebody else to talk to. Joy.",
70 "'Hello'? How original...")),
71
72 (r'(.*)',
73 ("I'm getting bored here. Become more interesting.",
74 "Either become more thrilling or get lost, buddy.",
75 "Change the subject before I die of fatal boredom."))
76 )
77
78 rude = Chat(pairs, reflections)
79
81 print "Unpleasant Chatbot (type 'quit' to exit)."
82 print '='*72
83 print "I suppose I should say hello."
84 converse(rude)
85
86 if __name__ == "__main__":
87 demo()
88