def persist(self, dir_name: Text) -> Dict[Text, Any]: """Persists this training data to disk and returns necessary information to load it again.""" data_file = os.path.join(dir_name, "training_data.json") write_to_file(data_file, self.as_json(indent=2)) return {"training_data": "training_data.json"}
def convert_training_data(data_file, out_file, output_format, language): td = training_data.load_data(data_file, language) if output_format == 'md': output = td.as_markdown() else: output = td.as_json(indent=2) write_to_file(out_file, output)
def test_remove_model_invalid(empty_model_dir): test_file = "something.else" test_content = "Some other stuff" test_file_path = os.path.join(empty_model_dir, test_file) write_to_file(test_file_path, test_content) with pytest.raises(ValueError) as e: remove_model(empty_model_dir) os.remove(test_file_path)
def persist(self, dir_name): # type: (Text) -> Dict[Text, Any] """Persists this training data to disk and returns necessary information to load it again.""" data_file = os.path.join(dir_name, "training_data.json") write_to_file(data_file, self.as_json(indent=2)) return { "training_data": "training_data.json" }
def persist( self, dir_name: Text, filename: Text = DEFAULT_TRAINING_DATA_OUTPUT_PATH ) -> Dict[Text, Any]: """Persists this training data to disk and returns necessary information to load it again.""" if not os.path.exists(dir_name): os.makedirs(dir_name) data_file = os.path.join(dir_name, filename) write_to_file(data_file, self.as_json(indent=2)) return {"training_data": DEFAULT_TRAINING_DATA_OUTPUT_PATH}
def persist(self, dir_name: Text, filename: Text = DEFAULT_TRAINING_DATA_OUTPUT_PATH ) -> Dict[Text, Any]: """Persists this training data to disk and returns necessary information to load it again.""" if not os.path.exists(dir_name): os.makedirs(dir_name) data_file = os.path.join(dir_name, filename) write_to_file(data_file, self.as_json(indent=2)) return { "training_data": DEFAULT_TRAINING_DATA_OUTPUT_PATH }
def save_json(data, filename): """Write out nlu classification to a file.""" utils.write_to_file(filename, json.dumps(data, indent=4, ensure_ascii=False))
def save_nlu_errors(errors, filename): """Write out nlu classification errors to a file.""" utils.write_to_file(filename, json.dumps(errors, indent=4, ensure_ascii=False)) logger.info("Model prediction errors saved to {}.".format(filename))
def dump(self, filename, training_data): """Writes a TrainingData object in markdown format to a file.""" s = self.dumps(training_data) utils.write_to_file(filename, s)
def convert_training_data(data_file, out_file, output_format, language): td = training_data.load_data(data_file, language) output = td.as_markdown() if output_format == 'md' else td.as_json(indent=2) write_to_file(out_file, output)