rasa.shared.nlu.training_data.util

You are viewing documentation for our open source project which is maintained by the community. If you want to get started building assistants with Rasa please check out our latest documentation here.

transform_entity_synonyms

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

Transforms the entity synonyms into a text->value dictionary.

get_file_format_extension

def 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:

Arguments:

Returns:

The resource file format.

remove_untrainable_entities_from

def remove_untrainable_entities_from(example: Dict[Text, Any]) -> None:

Remove untrainable entities from serialized training example example.

Entities with an untrainable extractor will be removed. Untrainable extractors are defined in rasa.nlu.constants.PRETRAINED_EXTRACTORS.

Arguments:

intent_response_key_to_template_key

def intent_response_key_to_template_key(intent_response_key: Text) -> Text:

Resolve the response template key for a given intent response key.

Arguments:

template_key_to_intent_response_key

def template_key_to_intent_response_key(template_key: Text) -> Text:

Resolve the intent response key for the given response template.

Arguments:

has_string_escape_chars

def has_string_escape_chars(s: Text) -> bool:

Checks whether there are any escape characters in the string.

encode_string

def encode_string(s: Text) -> Text:

Return an encoded python string.

decode_string

def decode_string(s: Text) -> Text:

Return a decoded python string.

build_entity

def 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:

Returns:

an entity dictionary

sparse_matrix_to_string

def sparse_matrix_to_string(m: scipy.sparse.spmatrix) -> Text:

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