Esempio n. 1
0
    def filter(cls, source_path: Path) -> bool:
        """Checks if the given training data file contains Core data in `Markdown`
        format and can be converted to `YAML`.

        Args:
            source_path: Path to the training data file.

        Returns:
            `True` if the given file can be converted, `False` otherwise
        """
        return MarkdownStoryReader.is_markdown_story_file(source_path)
Esempio n. 2
0
def _guess_reader(
    filename: Text,
    domain: Domain,
    template_variables: Optional[Dict] = None,
    use_e2e: bool = False,
) -> StoryReader:
    if YAMLStoryReader.is_yaml_story_file(filename):
        return YAMLStoryReader(domain, template_variables, use_e2e, filename)
    elif MarkdownStoryReader.is_markdown_story_file(filename):
        return MarkdownStoryReader(domain, template_variables, use_e2e,
                                   filename)
    raise ValueError(
        f"Failed to find a reader class for the story file `{filename}`. "
        f"Supported formats are "
        f"{', '.join(MARKDOWN_FILE_EXTENSIONS.union(YAML_FILE_EXTENSIONS))}.")
Esempio n. 3
0
def is_story_file(file_path: Text) -> bool:
    """Checks if a file is a Rasa story file.

    Args:
        file_path: Path of the file which should be checked.

    Returns:
        `True` if it's a story file, otherwise `False`.
    """
    from rasa.shared.core.training_data.story_reader.yaml_story_reader import (
        YAMLStoryReader, )
    from rasa.shared.core.training_data.story_reader.markdown_story_reader import (
        MarkdownStoryReader, )

    return YAMLStoryReader.is_yaml_story_file(
        file_path) or MarkdownStoryReader.is_markdown_story_file(file_path)