notice

This is unreleased documentation for Rasa Open Source Documentation Master/Unreleased version.
For the latest released documentation, see the latest version (2.0.x).

Version: Master/Unreleased

rasa.shared.nlu.training_data.util

transform_entity_synonyms

transform_entity_synonyms(synonyms, known_synonyms: Optional[Dict[Text, Any]] = None) -> Dict[Text, Any]

Transforms the entity synonyms into a text->value dictionary

get_file_format_extension

get_file_format_extension(resource_name: Text) -> Text

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(example: Dict[Text, Any]) -> None

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

intent_response_key_to_template_key(intent_response_key: Text) -> Text

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

template_key_to_intent_response_key(template_key: Text) -> Text

Resolve the intent response key for the given response template.

Arguments:

  • template_key - Name of the response template.
  • Returns - The corresponding intent response key.

encode_string

encode_string(s: Text) -> Text

Return an encoded python string.

decode_string

decode_string(s: Text) -> Text

Return a decoded python string.

build_entity

build_entity(start: int, end: int, value: Text, entity_type: Text, role: Optional[Text] = None, group: Optional[Text] = None, **kwargs: Any, ,) -> Dict[Text, Any]

Builds a standard entity dictionary.

Adds additional keyword parameters.

Arguments:

  • start - start position of entity
  • end - end position of entity
  • value - text value of the entity
  • entity_type - name of the entity type
  • role - role of the entity
  • group - group of the entity
  • **kwargs - additional parameters

Returns:

an entity dictionary