notice
This is unreleased documentation for Rasa Documentation Main/Unreleased version.
For the latest released documentation, see the latest version (3.x).
rasa.shared.nlu.training_data.util
transform_entity_synonyms
Transforms the entity synonyms into a text->value dictionary.
get_file_format_extension
Get the file extension based on training data format. It supports both a folder and a file, and tries to guess the format as follows:
- if the resource is a file and has a known format, return this format's extension
- if the resource is a folder and all the resources have the same known format, return it's extension
- otherwise, default to DEFAULT_FILE_FORMAT (yml).
Arguments:
resource_name
- The name of the resource, can be a file or a folder.
Returns:
The resource file format.
remove_untrainable_entities_from
Remove untrainable entities from serialised training example example
.
Entities with an untrainable extractor will be removed. Untrainable extractors
are defined in rasa.nlu.constants.PRETRAINED_EXTRACTORS
.
Arguments:
example
- Serialised training example to inspect.
intent_response_key_to_template_key
Resolve the response template key for a given intent response key.
Arguments:
intent_response_key
- retrieval intent with the response key suffix attached.Returns
- The corresponding response template.
template_key_to_intent_response_key
Resolve the intent response key for the given response template.
Arguments:
template_key
- Name of the response template.Returns
- The corresponding intent response key.
has_string_escape_chars
Checks whether there are any of the escape characters in the string.
encode_string
Return an encoded python string.
decode_string
Return a decoded python string.
build_entity
Builds a standard entity dictionary.
Adds additional keyword parameters.
Arguments:
start
- start position of entityend
- end position of entityvalue
- text value of the entityentity_type
- name of the entity typerole
- role of the entitygroup
- group of the entity**kwargs
- additional parameters
Returns:
an entity dictionary
sparse_matrix_to_string
Turns a sparse matrix into a string.
Will return a line "(i,j) v" for each value in the matrix.
taken from official scipy source to operate on full sparse matrix to not have
to change the maxprint
property in-place.
https://github.com/scipy/scipy/blob/v1.7.0/scipy/sparse/base.py#L258