def add_default(self, chunk): if len(self.current): if not self.current.endswith(chunk): if self.singularize: chunk = words.singularize(chunk) self.result[self.current].append(chunk) else: self.command_output = " " + chunk
def parse_command(self, command, result): to_parse = command.lower() matches = self.regexp.match(to_parse) if matches and matches.groupdict(): item_list = matches.groupdict()["request"] if len(item_list.split()) == 1: item_list = words.singularize(item_list) result["action"] = "search" result["what"]["list"] = item_list command = "" elif len(item_list) == 0: command = "" result["action"] = "search" result["what"]["list"] = "all items" return command, result