예제 #1
0
 def persist_nlg(self, filename: Text) -> None:
     if data.is_likely_yaml_file(filename):
         rasa.nlu.utils.write_to_file(filename, self.nlg_as_yaml())
     elif data.is_likely_markdown_file(filename):
         nlg_serialized_data = self.nlg_as_markdown()
         if nlg_serialized_data:
             rasa.nlu.utils.write_to_file(filename, nlg_serialized_data)
     else:
         ValueError(
             "Unsupported file format detected. Supported file formats are 'md' "
             "and 'yml'.")
예제 #2
0
    def persist_nlu(self, filename: Text = DEFAULT_TRAINING_DATA_OUTPUT_PATH) -> None:

        if data.is_likely_json_file(filename):
            rasa.nlu.utils.write_to_file(filename, self.nlu_as_json(indent=2))
        elif data.is_likely_markdown_file(filename):
            rasa.nlu.utils.write_to_file(filename, self.nlu_as_markdown())
        elif data.is_likely_yaml_file(filename):
            rasa.nlu.utils.write_to_file(filename, self.nlu_as_yaml())
        else:
            ValueError(
                "Unsupported file format detected. Supported file formats are 'json' "
                "and 'md'."
            )
예제 #3
0
def _get_reader(
    filename: Text,
    domain: Domain,
    template_variables: Optional[Dict] = None,
    use_e2e: bool = False,
) -> StoryReader:

    if data.is_likely_markdown_file(filename):
        return MarkdownStoryReader(domain, template_variables, use_e2e,
                                   filename)
    elif data.is_likely_yaml_file(filename):
        return YAMLStoryReader(domain, template_variables, use_e2e, filename)
    else:
        # This is a use case for uploading the story over REST API.
        # The source file has a random name.
        return _guess_reader(filename, domain, template_variables, use_e2e)
예제 #4
0
def test_is_md_file(path, is_md):
    assert data.is_likely_markdown_file(path) == is_md