notice

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

Version: 2.x

rasa.shared.nlu.training_data.formats.rasa_yaml

RasaYAMLReader Objects

class RasaYAMLReader(TrainingDataReader)

Reads YAML training data and creates a TrainingData object.

validate

| validate(string: Text) -> None

Check if the string adheres to the NLU yaml data schema.

If the string is not in the right format, an exception will be raised.

reads

| reads(string: Text, **kwargs: Any) -> "TrainingData"

Reads TrainingData in YAML format from a string.

Arguments:

  • string - String with YAML training data.
  • **kwargs - Keyword arguments.

Returns:

New TrainingData object with parsed training data.

is_yaml_nlu_file

| @staticmethod
| is_yaml_nlu_file(filename: Union[Text, Path]) -> bool

Checks if the specified file possibly contains NLU training data in YAML.

Arguments:

  • filename - name of the file to check.

Returns:

True if the filename is possibly a valid YAML NLU file, False otherwise.

Raises:

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

RasaYAMLWriter Objects

class RasaYAMLWriter(TrainingDataWriter)

Writes training data into a file in a YAML format.

dumps

| dumps(training_data: "TrainingData") -> Text

Turns TrainingData into a string.

dump

| dump(target: Union[Text, Path, StringIO], training_data: "TrainingData") -> None

Writes training data into a file in a YAML format.

Arguments:

  • target - Name of the target object to write the YAML to.
  • training_data - TrainingData object.

training_data_to_dict

| @classmethod
| training_data_to_dict(cls, training_data: "TrainingData") -> Optional[OrderedDict]

Represents NLU training data to a dict/list structure ready to be serialized as YAML.

Arguments:

  • training_data - TrainingData to convert.

Returns:

OrderedDict containing all training data.