class ChitChat(object): def __init__(self): self.BOT_PREDICATES = { "name": "KanoBot", "birthday": "January 1st 1969", "location": "London", "master": "Judoka", "website": "https://github.com/brandonjackson/make-chatterbot", "gender": "", "age": "", "size": "", "religion": "", "party": "" } self.DEVNULL = open(os.devnull, 'wb') self.k = MyKernel() # Load the AIML files on first load, and then save as "brain" for speedier startup if os.path.isfile("cache/standard.brn") is False: self.k.learn("aiml/standard/std-startup.xml") self.k.respond("load aiml b") self.k.saveBrain("cache/standard.brn") else: self.k.loadBrain("cache/standard.brn") # Give the bot a name and lots of other properties for key, val in self.BOT_PREDICATES.items(): self.k.setBotPredicate(key, val) # Start Infinite Loop def chat(self, sentence): # Prompt user for input # input = raw_input("> ") input = sentence # Send input to bot and print chatbot's response matchedPattern = self.k.matchedPattern( input) # note: this has to come before the # call to respond as to reflect # the correct history response = self.k.respond(input) return response
pass # Create Kernel (using our custom version of the aiml kernel class) k = MyKernel() # Load the AIML files on first load, and then save as "brain" for speedier startup if os.path.isfile("cache/standard.brn") is False: #FIXME undo this. k.learn("aiml/std-startup.xml") k.respond("load aiml b") k.saveBrain("cache/standard.brn") else: k.loadBrain("cache/standard.brn") # Give the bot a name and lots of other properties for key,val in BOT_PREDICATES.items(): k.setBotPredicate(key, val) # Init STT engine recognizer = sr.Recognizer() # Start Infinite Loop while True: # Prompt user for input setEyes(0) #input = raw_input("> ") with sr.Microphone(device_index=2) as source: audio_input = recognizer.listen(source) try: input = recognizer.recognize(audio_input) except LookupError: input = 'Kauderwelsch'
"location": "Kanpur", "master": "I have no Master", "website":"follow me on twitter", "gender": "Female", "age": "20", "size": "", "religion": "Humanity", "party": "All night !" } k = MyKernel() k.learn("aiml/standard/std-startup.xml") k.respond("LOAD AIML B") for key,val in BOT_INFO.items(): k.setBotPredicate(key,val) class PopupBox(ModalView): ''' :Events: `on_open`: Fired when the Popup is opened. `on_dismiss`: Fired when the Popup is closed. If the callback returns True, the dismiss will be canceled. ''' title = StringProperty('No title') '''String that represents the title of the popup. :attr:`title` is a :class:`~kivy.properties.StringProperty` and defaults to