Package nltk :: Package chat
[hide private]
[frames] | no frames]

Source Code for Package nltk.chat

 1  # Natural Language Toolkit: Chatbots 
 2  # 
 3  # Copyright (C) 2001-2008 NLTK Project 
 4  # Authors: Steven Bird <[email protected]> 
 5  # URL: <http://nltk.org> 
 6  # For license information, see LICENSE.TXT 
 7   
 8  # Based on an Eliza implementation by Joe Strout <[email protected]>, 
 9  # Jeff Epler <[email protected]> and Jez Higgins <[email protected]>. 
10   
11  """ 
12  A class for simple chatbots.  These perform simple pattern matching on sentences 
13  typed by users, and respond with automatically generated sentences. 
14   
15  These chatbots may not work using the windows command line or the 
16  windows IDLE GUI. 
17  """ 
18   
19  from util import * 
20  from eliza import eliza_chat 
21  from iesha import iesha_chat 
22  from rude import rude_chat 
23  from suntsu import suntsu_chat 
24  from zen import zen_chat 
25   
26 -def demo():
27 import sys 28 print 'Which chatbot would you like to talk to?' 29 print ' 1: Eliza (psycho-babble)' 30 print ' 2: Iesha (teen anime junky)' 31 print ' 3: Rude' 32 print ' 4: Suntsu (Chinese sayings)' 33 print ' 5: Zen (gems of wisdom)' 34 print '\nPlease enter 1-5 ', 35 choice = sys.stdin.readline().strip() 36 print 37 if choice not in '12345': 38 print 'Bad chatbot number' 39 return 40 41 chatbot = [eliza_chat, iesha_chat, rude_chat, suntsu_chat, zen_chat][int(choice)-1] 42 chatbot()
43