rasa.shared.nlu.training_data.formats.rasa_yaml
RasaYAMLReader Objects
Reads YAML training data and creates a TrainingData object.
validate
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 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
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
Writes training data into a file in a YAML format.
dumps
Turns TrainingData into a string.
dump
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
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.
process_intents
Serializes the intents.
process_synonyms
Serializes the synonyms.
process_regexes
Serializes the regexes.
process_lookup_tables
Serializes the look up tables.
Arguments:
training_data
- The training data object with potential look up tables.
Returns:
The serialized lookup tables.
process_training_examples_by_key
Prepares training examples to be written to YAML.
This can be any NLU training data (intent examples, lookup tables, etc.)
Arguments:
training_examples
- Multiple training examples. Mappings in case additional values were specified for an example (e.g. metadata) or just the plain value.key_name
- The top level key which the examples belong to (e.g.intents
)key_examples
- The sub key which the examples should be added to (e.g.examples
).example_extraction_predicate
- Function to extract example value (e.g. the the text for an intent example)
Returns:
NLU training data examples prepared for writing to YAML.