diff --git a/src/programy/clients/twitter.py b/src/programy/clients/twitter.py index 5d3abec37..9bcd3216e 100644 --- a/src/programy/clients/twitter.py +++ b/src/programy/clients/twitter.py @@ -189,7 +189,7 @@ def _process_status_question(self, userid, text): logging.debug(status) if logging.getLogger().isEnabledFor(logging.DEBUG): - logging.debug("Sending status response [@%s] [%s]", (user.screen_name, response)) + logging.debug("Sending status response [@%s] [%s]",user.screen_name, response) self._api.update_status(status) diff --git a/src/programy/extensions/maps/maps.py b/src/programy/extensions/maps/maps.py index a517d8377..d4eb7c87a 100644 --- a/src/programy/extensions/maps/maps.py +++ b/src/programy/extensions/maps/maps.py @@ -22,6 +22,9 @@ class GoogleMapsExtension(Extension): + def get_geo_locator(self): + return GoogleMaps() + # execute() is the interface that is called from the tag in the AIML def execute(self, bot, clientid, data): if logging.getLogger().isEnabledFor(logging.DEBUG): @@ -32,7 +35,7 @@ def execute(self, bot, clientid, data): from_place = splits[1] to_place = splits[2] - googlemaps = GoogleMaps(bot.license_keys) + googlemaps = self.get_geo_locator() if command == "DISTANCE": distance = googlemaps.get_distance_between_addresses(from_place, to_place) diff --git a/src/programy/parser/tokenizer.py b/src/programy/parser/tokenizer.py index 97de97fdd..6fe4bbab0 100644 --- a/src/programy/parser/tokenizer.py +++ b/src/programy/parser/tokenizer.py @@ -53,6 +53,10 @@ def _is_chinese_char(c): (0x31C0, 0x31EF)] return any(s <= ord(c) <= e for s, e in r) + def _is_wildchar(self, ch): + MATCH_CHARS = ['^', '#', '', '*'] + return bool(ch in MATCH_CHARS) + def texts_to_words(self, texts): if not texts: return [] @@ -63,16 +67,21 @@ def texts_to_words(self, texts): if CjkTokenizer._is_chinese_char(ch): if len(last_word) > 0: words.append(last_word) - last_word = ch - else: - words.append(ch) + last_word = '' + words.append(ch) else: - if ch == self.split_chars: + if self._is_wildchar(ch): if len(last_word) > 0: words.append(last_word) last_word = '' + words.append(ch) else: - last_word += ch + if ch == self.split_chars: + if len(last_word) > 0: + words.append(last_word) + last_word = '' + else: + last_word += ch if len(last_word) > 0: words.append(last_word) diff --git a/test/programytest/extensions/maps/maps.aiml b/test/programytest/extensions/maps/maps.aiml index d1237342b..5dfcced6b 100644 --- a/test/programytest/extensions/maps/maps.aiml +++ b/test/programytest/extensions/maps/maps.aiml @@ -82,7 +82,7 @@