Spaces:
Configuration error
Configuration error
| import aiml | |
| import os | |
| kernel = aiml.Kernel() | |
| if os.path.isfile("bot_brain.brn"): | |
| kernel.bootstrap(brainFile = "bot_brain.brn") | |
| else: | |
| kernel.bootstrap(learnFiles = os.path.abspath("aiml/std-startup.xml"), commands = "load aiml b") | |
| kernel.saveBrain("bot_brain.brn") | |
| # kernel now ready for use | |
| while True: | |
| message = raw_input("Enter your message to the bot: ") | |
| if message == "quit": | |
| exit() | |
| elif message == "save": | |
| kernel.saveBrain("bot_brain.brn") | |
| else: | |
| bot_response = kernel.respond(message) | |
| print bot_response | |