From 123191fcf8b845faf3885bf20f174827e24056e0 Mon Sep 17 00:00:00 2001 From: keithsterling Date: Wed, 7 Dec 2016 21:16:47 +0000 Subject: [PATCH] Fixed a upper/lower case issue impacting --- README.txt | 2 +- bots/tutorial/aiml/coffee.aiml | 20 +++++++++ bots/tutorial/config.yaml | 52 ++++++++++++++++++++++++ bots/tutorial/config/client.yaml | 37 ----------------- bots/tutorial/config/logging.yaml | 19 --------- bots/tutorial/config/postprocessors.conf | 2 + bots/tutorial/config/preprocessors.conf | 3 +- bots/tutorial/logging.yaml | 17 ++++++++ src/programy/bot.py | 9 ++-- src/programy/clients.py | 2 +- 10 files changed, 101 insertions(+), 62 deletions(-) create mode 100644 bots/tutorial/aiml/coffee.aiml create mode 100644 bots/tutorial/config.yaml delete mode 100644 bots/tutorial/config/client.yaml delete mode 100644 bots/tutorial/config/logging.yaml create mode 100644 bots/tutorial/config/postprocessors.conf create mode 100644 bots/tutorial/logging.yaml diff --git a/README.txt b/README.txt index 4695df662..757c475c8 100644 --- a/README.txt +++ b/README.txt @@ -6,6 +6,6 @@ http://alicebot.blogspot.co.uk/2013/01/aiml-20-draft-specification-released.html For full documentation, tutorials and other helpful information, see the GitHub pages site https://keiffster.github.io/program-y/ -This is a version 0.2.0 implementation, it covers almost all the 2.0 grammar and has very high unit test coverage both of code and AIML files along with a better configuration settings and a few other changes. It now also includes external services Pandora, Pannous, Wikipedia and Generic REST +This is a version 0.2.1 implementation, it covers almost all the 2.0 grammar and has very high unit test coverage both of code and AIML files along with a better configuration settings and a few other changes. It now also includes external services Pandora, Pannous, Wikipedia and Generic REST diff --git a/bots/tutorial/aiml/coffee.aiml b/bots/tutorial/aiml/coffee.aiml new file mode 100644 index 000000000..a9070dbfa --- /dev/null +++ b/bots/tutorial/aiml/coffee.aiml @@ -0,0 +1,20 @@ + + + + + I LIKE COFFEE + + + + + YES + DO YOU TAKE CREAM OR SUGAR IN YOUR COFFEE? + + + + + NO + DO YOU TAKE CREAM OR SUGAR IN YOUR COFFEE? + + + \ No newline at end of file diff --git a/bots/tutorial/config.yaml b/bots/tutorial/config.yaml new file mode 100644 index 000000000..0e15c30cd --- /dev/null +++ b/bots/tutorial/config.yaml @@ -0,0 +1,52 @@ + +brain: + + supress_warnings: true + + allow_system_aiml: true + allow_learn_aiml: true + allow_learnf_aiml: true + + files: + aiml: + files: $BOT_ROOT/aiml + extension: .aiml + directories: false + sets: + files: $BOT_ROOT/sets + extension: .txt + directories: false + maps: + files: $BOT_ROOT/maps + extension: .txt + directories: false + denormal: $BOT_ROOT/config/denormal.txt + normal: $BOT_ROOT/config/normal.txt + gender: $BOT_ROOT/config/gender.txt + person: $BOT_ROOT/config/person.txt + person2: $BOT_ROOT/config/person2.txt + predicates: $BOT_ROOT/config/predicates.txt + pronouns: $BOT_ROOT/config/pronouns.txt + properties: $BOT_ROOT/config/properties.txt + triples: $BOT_ROOT/config/triples.txt + preprocessors: $BOT_ROOT/config/preprocessors.conf + postprocessors: $BOT_ROOT/config/postprocessors.conf + + services: + REST: + path: programy.utils.services.rest.GenericRESTService + Pannous: + path: programy.utils.services.pannous.PannousService + login: test-user + Pandora: + path: programy.utils.services.pandora.PandoraService + botid: f5d922d97e345aa1 + Wikipedia: + path: programy.utils.services.wikipediaservice.WikipediaService + +bot: + prompt: ">>>" + initial_question: HI, HOW CAN I HELP YOU TODAY? + default_response: SORRY, I DON'T HAVE AN ANSWER FOR THAT! + exit_response: SO LONG, AND THANKS FOR THE FISH! + diff --git a/bots/tutorial/config/client.yaml b/bots/tutorial/config/client.yaml deleted file mode 100644 index 79f3d6562..000000000 --- a/bots/tutorial/config/client.yaml +++ /dev/null @@ -1,37 +0,0 @@ - -brain: - - supress_warnings: true - - allow_system_aiml: true - allow_learn_aiml: true - allow_learnf_aiml: true - - files: - aiml: - files: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/aiml - extension: .aiml - directories: false - sets: - files: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/sets - extension: .txt - directories: false - maps: - files: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/maps - extension: .txt - directories: false - denormal: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/config/denormal.txt - normal: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/config/normal.txt - gender: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/config/gender.txt - person: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/config/person.txt - person2: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/config/person2.txt - predicates: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/config/predicates.txt - pronouns: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/config/pronouns.txt - properties: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/config/properties.txt - triples: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/config/triples.txt - preprocessors: /Users/keithsterling/Documents/Development/Python/Projects/AIML/program-y/bots/tutorial/config/preprocessors.txt - -bot: - prompt: ">>>" - default_response: Sorry, I don't have an answer for that! - exit_response: So long, and thanks for the fish! \ No newline at end of file diff --git a/bots/tutorial/config/logging.yaml b/bots/tutorial/config/logging.yaml deleted file mode 100644 index bebd0cac1..000000000 --- a/bots/tutorial/config/logging.yaml +++ /dev/null @@ -1,19 +0,0 @@ -logging: - version: 1 - formatters: - simple: - format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s' - handlers: - console: - class: logging.StreamHandler - level: ERROR - formatter: simple - stream: ext://sys.stdout - loggers: - simpleExample: - level: ERROR - handlers: [console] - propagate: no - root: - level: ERROR - handlers: [console] diff --git a/bots/tutorial/config/postprocessors.conf b/bots/tutorial/config/postprocessors.conf new file mode 100644 index 000000000..a0e41d929 --- /dev/null +++ b/bots/tutorial/config/postprocessors.conf @@ -0,0 +1,2 @@ +programy.processors.post.denormalize.DenormalizePostProcessor +programy.processors.post.cleanup.CleanUpPostProcessor diff --git a/bots/tutorial/config/preprocessors.conf b/bots/tutorial/config/preprocessors.conf index f37c3b3fb..e63658737 100644 --- a/bots/tutorial/config/preprocessors.conf +++ b/bots/tutorial/config/preprocessors.conf @@ -1 +1,2 @@ -programy.processing.WordPreProcessor +programy.processors.pre.normalize.NormalizePreProcessor +programy.processors.pre.cleanup.CleanUpPreProcessor diff --git a/bots/tutorial/logging.yaml b/bots/tutorial/logging.yaml new file mode 100644 index 000000000..ad15f27c8 --- /dev/null +++ b/bots/tutorial/logging.yaml @@ -0,0 +1,17 @@ +version: 1 +disable_existing_loggers: False + +formatters: + simple: + format: '%(asctime)s %(name)-10s %(levelname)-7s %(message)s' + +handlers: + file: + class: logging.handlers.RotatingFileHandler + formatter: simple + filename: /tmp/rosiebot.log + +root: + level: DEBUG + handlers: + - file diff --git a/src/programy/bot.py b/src/programy/bot.py index 7fe292dc9..ec53aade4 100644 --- a/src/programy/bot.py +++ b/src/programy/bot.py @@ -108,15 +108,18 @@ def ask_question(self, clientid: str, text: str, srai=False): else: parent_question = conversation.current_question() + answers = [] for each_sentence in question._sentences: response = self.brain.ask_question(self, clientid, each_sentence, parent_question) if response is not None: logging.debug("Raw Response (%s): %s"%(clientid, response)) - each_sentence.response = self.brain.post_process_response(self, clientid, response).strip() - logging.debug("Processed Response (%s): %s"%(clientid, each_sentence.response)) + each_sentence.response = response + answer = self.brain.post_process_response(self, clientid, response).strip() + answers.append(answer) + logging.debug("Processed Response (%s): %s"%(clientid, answer)) else: each_sentence.response = self.default_response - return question.combine_answers() + return ". ".join([sentence for sentence in answers if sentence is not None]) diff --git a/src/programy/clients.py b/src/programy/clients.py index 7556d1abc..01a4c2575 100644 --- a/src/programy/clients.py +++ b/src/programy/clients.py @@ -129,7 +129,7 @@ def run(self): logging.info ("Entering conversation loop...") running = True self.display_response(self.bot.get_version_string) - self.display_response(self.bot.initial_question) + self.display_response(self.bot.brain.post_process_response(self.bot, self.clientid, self.bot.initial_question)) while running is True: try: question = self.get_question()