Exemple #1
0
def _guess_reader(filename: Text, domain: Domain) -> StoryReader:
    if YAMLStoryReader.is_stories_file(filename):
        return YAMLStoryReader(domain, filename)

    raise ValueError(
        f"Failed to find a reader class for the story file `{filename}`. "
        f"Supported formats are "
        f"{', '.join(YAML_FILE_EXTENSIONS)}.")
Exemple #2
0
    def filter(cls, source_path: Path) -> bool:
        """Only accept YAML story files.

        Args:
            source_path: Path to a training data file.

        Returns:
            `True` if the given file is a YAML stories file, `False` otherwise.
        """
        return YAMLStoryReader.is_stories_file(source_path)
Exemple #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_stories_file(
        file_path) or MarkdownStoryReader.is_stories_file(file_path)
Exemple #4
0
    def _init_from_directory(self, path: Text) -> None:
        for parent, _, files in os.walk(path, followlinks=True):
            for file in files:
                full_path = os.path.join(parent, file)
                if not self.is_imported(full_path):
                    # Check next file
                    continue

                if YAMLStoryReader.is_test_stories_file(full_path):
                    self._e2e_story_paths.append(full_path)
                elif Domain.is_domain_file(full_path):
                    self._domain_paths.append(full_path)
                elif rasa.shared.data.is_nlu_file(full_path):
                    self._nlu_paths.append(full_path)
                elif YAMLStoryReader.is_stories_file(full_path):
                    self._story_paths.append(full_path)
                elif rasa.shared.data.is_config_file(full_path):
                    self._init_from_file(full_path)