Beispiel #1
0
    def to_natural_language(self):
        prompt = ""
        user_config = " and ".join(["{}: {}".format(k, v) for k, v in                                   \
                                    self.last_system_belief.items()                                     \
                                    if k in self.frame.content                                          \
                                    .keys() and is_value(v)])
        if len(self.data) == 1:
            prompt += ("is this {} what you were looking"
                       " for?").format(self.frame.entity)
        else:
            prompt += ("there are more than one {} with {}. here:"
                       "").format(self.frame.entity, user_config)

        for i, result in enumerate(self.data):
            prompt += (" [{}. {}],".format(i + 1, ", ".join(["{}: {}".format(k,
                                              v) for k, v in result.items()])))
        prompt = prompt.strip(",") + ". "
        if self.frame.can_advance_results_list():
            prompt += ("there are also other results matching your criteria."
                      "  ask me to show you more if you want to see them. ")
        if self.frame.can_restore_results_list():
            prompt += ("if you want to see previous results, or the first "
                       "results of the list, just ask me.")

        return prompt.strip()
    def to_natural_language(self):
        prompt = ""
        db = Database.get_instance()
        entity = self.frame.entity.replace("_", " ")
        belief = db.remove_fkeys_from_result_set(self.last_system_belief)
        user_config = " and ".join(["{} {}".format(db.slot_to_column(k)                                 \
                                    .replace("_", " "), v) for k, v in                                  \
                                    belief.items() if k in self.frame                                   \
                                    .get_all_slots(exclude_fkeys=True)                                  \
                                    and is_value(v)])
        if len(self.data) == 1:
            prompt += ("is this {} what you were looking"
                       " for?").format(entity)
        else:
            prompt += ("there are more than one {} with {}. here:"
                       "").format(entity, user_config)

        for i, result in enumerate(self.data):
            prompt += (" [{}. {}],".format(i + 1, ", ".join(["{}: {}".format(db                         \
                                            .slot_to_column(k).replace("_", " "),
                                                v) for k, v in result.items()])))
        prompt = prompt.strip(",") + ". "
        if self.frame.can_advance_results_list():
            prompt += ("there are also other results matching your criteria."
                       "  ask me to show you more if you want to see them. ")
        if self.frame.can_restore_results_list():
            prompt += ("if you want to see previous results, or the first "
                       "results of the list, just ask me.")

        return prompt.replace("_", " ").strip()
Beispiel #3
0
    def to_natural_language(self):
        if self.data:
            prompt = random.choice(["understood.", "alright.", "ok.", "got it."])
        else:
            user_config = " and ".join(["{}: {}".format(k, v) for k, v in                                   \
                                        self.last_system_belief.items()                                     \
                                        if k in self.frame.content                                          \
                                        .keys() and is_value(v)])
            
            prompt = ("unfortunately, i couldn't find any {} with {}"
                     ".").format(self.frame.entity, user_config)

        return prompt
    def to_natural_language(self):
        if self.data:
            prompt = random.choice(
                ["understood.", "alright.", "ok.", "got it."])
        else:
            db = Database.get_instance()
            belief = db.remove_fkeys_from_result_set(self.last_system_belief)
            user_config = " and ".join(["{} {}".format(db.slot_to_column(k)                             \
                                        .replace("_", " "), v) for k, v in                              \
                                        belief.items() if k in self                                     \
                                        .frame.content.keys() and
                                        is_value(v)])

            prompt = ("unfortunately, i couldn't find any {} with {}"
                      ".").format(self.frame.entity.replace("_", " "),
                                  user_config)

        return prompt
 def to_string_verbose(self):
     content = self.frame.history[-1].items()
     return self.name + str({k : v for k, v in content if is_value(v)                                \
                                 and k in self.frame.get_all_slots()})