notice

This is unreleased documentation for Rasa Documentation Main/Unreleased version.
For the latest released documentation, see the latest version (3.x).

Version: Main/Unreleased

rasa.shared.core.training_data.story_reader.yaml_story_reader

YAMLStoryReader Objects

class YAMLStoryReader(StoryReader)

Class that reads Core training data and rule data in YAML format.

from_reader

@classmethod
def from_reader(cls, reader: "YAMLStoryReader") -> "YAMLStoryReader"

Create a reader from another reader.

Arguments:

  • reader - Another reader.

Returns:

A new reader instance.

read_from_file

def read_from_file(filename: Union[Text, Path],
skip_validation: bool = False) -> List[StoryStep]

Read stories or rules from file.

Arguments:

  • filename - Path to the story/rule file.
  • skip_validation - True if the file was already validated e.g. when it was stored in the database.

Returns:

StorySteps read from filename.

read_from_string

def read_from_string(string: Text,
skip_validation: bool = False) -> List[StoryStep]

Read stories or rules from a string.

Arguments:

  • string - Unprocessed YAML file content.
  • skip_validation - True if the string was already validated e.g. when it was stored in the database.

Returns:

StorySteps read from string.

read_from_parsed_yaml

def read_from_parsed_yaml(
parsed_content: Dict[Text, Union[Dict, List]]) -> List[StoryStep]

Read stories from parsed YAML.

Arguments:

  • parsed_content - The parsed YAML as a dictionary.

Returns:

The parsed stories or rules.

is_stories_file

@classmethod
def is_stories_file(cls, file_path: Union[Text, Path]) -> bool

Check if file contains Core training data or rule data in YAML format.

Arguments:

  • file_path - Path of the file to check.

Returns:

True in case the file is a Core YAML training data or rule data file, False otherwise.

Raises:

  • YamlException - if the file seems to be a YAML file (extension) but can not be read / parsed.

is_test_stories_file

@classmethod
def is_test_stories_file(cls, file_path: Union[Text, Path]) -> bool

Checks if a file is a test conversations file.

Arguments:

  • file_path - Path of the file which should be checked.

Returns:

True if it's a conversation test file, otherwise False.

unpack_regex_message

@staticmethod
def unpack_regex_message(
message: Message,
domain: Optional[Domain] = None,
entity_extractor_name: Optional[Text] = None) -> Message

Unpacks the message if TEXT contains an encoding of attributes.

Arguments:

  • message - some message
  • domain - the domain
  • entity_extractor_name - An extractor name which should be added for the entities.

Returns:

the given message if that message does not need to be unpacked, and a new message with the extracted attributes otherwise

StoryParser Objects

class StoryParser(YAMLStoryReader)

Encapsulate story-specific parser behavior.

RuleParser Objects

class RuleParser(YAMLStoryReader)

Encapsulate rule-specific parser behavior.