def persist_clean(self, filename: Text) -> None: """Write domain to a file. Strips redundant keys with default values.""" data = self.as_dict() for idx, intent_info in enumerate(data["intents"]): for name, intent in intent_info.items(): if intent.get("use_entities"): data["intents"][idx] = name for slot in data["slots"].values(): if slot["initial_value"] is None: del slot["initial_value"] if slot["auto_fill"]: del slot["auto_fill"] if slot["type"].startswith('rasa_core.slots'): slot["type"] = Slot.resolve_by_type(slot["type"]).type_name if data["config"]["store_entities_as_slots"]: del data["config"]["store_entities_as_slots"] # clean empty keys data = { k: v for k, v in data.items() if v != {} and v != [] and v is not None } utils.dump_obj_as_yaml_to_file(filename, data)
def persist_clean(self, filename: Text) -> None: """Write domain to a file. Strips redundant keys with default values.""" data = self.as_dict() for idx, intent_info in enumerate(data["intents"]): for name, intent in intent_info.items(): if intent.get("use_entities"): data["intents"][idx] = name for name, slot in data["slots"].items(): if slot["initial_value"] is None: del slot["initial_value"] utils.dump_obj_as_yaml_to_file(filename, data)
def persist(self, filename): additional_config = { "store_entities_as_slots": self.store_entities_as_slots } action_names = self.action_names[len(Domain.DEFAULT_ACTIONS):] domain_data = { "config": additional_config, "intents": self.intents, "entities": self.entities, "slots": self._slot_definitions(), "templates": self.templates, "actions": self._action_classes, # class names of the actions "action_names": action_names, # names in stories "action_factory": self._factory_name } utils.dump_obj_as_yaml_to_file(filename, domain_data)
def persist(self, filename: Text) -> None: """Write domain to a file.""" domain_data = self.as_dict() utils.dump_obj_as_yaml_to_file(filename, domain_data)
def persist(self, filename): domain_data = self.as_dict() utils.dump_obj_as_yaml_to_file(filename, domain_data)
def persist(self, filename): domain_data = self.as_dict() utils.dump_obj_as_yaml_to_file(filename, domain_data)