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"}
예제 #2
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
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"
        }
예제 #6
0
    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}
예제 #7
0
    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
        }
예제 #8
0
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))
예제 #9
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))
예제 #10
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)
예제 #11
0
파일: test.py 프로젝트: marami52/rasa_nlu
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))
예제 #12
0
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)
예제 #13
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)
예제 #14
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))