def test_nlu_intents_are_converted(tmpdir: Path):
    converted_data_folder = tmpdir / "converted_data"
    os.mkdir(converted_data_folder)

    training_data_folder = tmpdir / "data"
    os.makedirs(training_data_folder, exist_ok=True)
    training_data_file = Path(training_data_folder) / "responses.md"

    simple_nlg_md = ("## ask name\n"
                     "* chitchat/ask_name\n"
                     "- my name is Sara, Rasa's documentation bot!\n")

    with open(training_data_file, "w") as f:
        f.write(simple_nlg_md)

    NLGMarkdownToYamlConverter().convert_and_write(training_data_file,
                                                   converted_data_folder)

    assert len(os.listdir(converted_data_folder)) == 1

    with open(f"{converted_data_folder}/responses_converted.yml", "r") as f:
        content = f.read()
        assert content == (
            f'version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"\n'
            "responses:\n"
            "  chitchat/ask_name:\n"
            "  - text: my name is Sara, Rasa's documentation bot!\n")
Ejemplo n.º 2
0
def _convert_nlg_data(args: argparse.Namespace) -> None:
    from rasa.nlu.training_data.converters.nlg_markdown_to_yaml_converter import (
        NLGMarkdownToYamlConverter, )

    if args.format == "yaml":
        _convert_to_yaml(args, NLGMarkdownToYamlConverter())
    else:
        print_error_and_exit(
            "Could not recognize output format. Supported output formats: "
            "'yaml'. Specify the desired output format with '--format'.")
Ejemplo n.º 3
0
def _convert_nlg_data(args: argparse.Namespace) -> None:
    from rasa.nlu.training_data.converters.nlg_markdown_to_yaml_converter import (
        NLGMarkdownToYamlConverter, )

    if args.format == "yaml":
        rasa.utils.common.run_in_loop(
            _convert_to_yaml(args, NLGMarkdownToYamlConverter()))
        telemetry.track_data_convert(args.format, "nlg")
    else:
        rasa.shared.utils.cli.print_error_and_exit(
            "Could not recognize output format. Supported output formats: "
            "'yaml'. Specify the desired output format with '--format'.")
def test_converter_filters_correct_files(training_data_file: Text,
                                         should_filter: bool):
    assert should_filter == NLGMarkdownToYamlConverter.filter(
        Path(training_data_file))