notice

This is documentation for Rasa Open Source Documentation v2.0.x, which is no longer actively maintained.
For up-to-date documentation, see the latest version (2.1.x).

Version: 2.0.x

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
| from_reader(cls, reader: "YAMLStoryReader") -> "YAMLStoryReader"

Create a reader from another reader.

Arguments:

  • reader - Another reader.

Returns:

A new reader instance.

read_from_file

| read_from_file(filename: Union[Text, Path]) -> List[StoryStep]

Read stories or rules from file.

Arguments:

  • filename - Path to the story/rule file.

Returns:

StorySteps read from filename.

read_from_string

| read_from_string(string: Text) -> List[StoryStep]

Read stories or rules from a string.

Arguments:

  • string - Unprocessed YAML file content.

Returns:

StorySteps read from string.

read_from_parsed_yaml

| 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
| is_stories_file(cls, file_path: Text) -> 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_key_in_yaml

| @classmethod
| is_key_in_yaml(cls, file_path: Text, *keys: Text) -> bool

Check if all keys are contained in the parsed dictionary from a yaml file.

Arguments:

  • file_path - path to the yaml file
  • keys - keys to look for

Returns:

True if all the keys are contained in the 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
| 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.

StoryParser Objects

class StoryParser(YAMLStoryReader)

Encapsulate story-specific parser behavior.

RuleParser Objects

class RuleParser(YAMLStoryReader)

Encapsulate rule-specific parser behavior.