示例#1
0
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)
示例#2
0
    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"}
示例#3
0
 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)
示例#4
0
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))