notice

This is unreleased documentation for Rasa Documentation Main/Unreleased version.
For the latest released documentation, see the latest version (3.x).

Version: Main/Unreleased

rasa.shared.nlu.training_data.entities_parser

EntityAttributes Objects

class EntityAttributes(NamedTuple)

Attributes of an entity defined in markdown data.

find_entities_in_training_example

def find_entities_in_training_example(example: Text) -> List[Dict[Text, Any]]

Extracts entities from an annotated utterance.

Arguments:

  • example - Annotated utterance.

Returns:

Extracted entities.

extract_entity_attributes

def extract_entity_attributes(match: Match) -> EntityAttributes

Extract the entity attributes, i.e. type, value, etc., from the regex match.

Arguments:

  • match - Regex match to extract the entity attributes from.

Returns:

EntityAttributes object.

extract_entity_attributes_from_dict

def extract_entity_attributes_from_dict(entity_text: Text,
match: Match) -> EntityAttributes

Extract entity attributes from dict format.

Arguments:

  • entity_text - Original entity text.
  • match - Regex match.

Returns:

Extracted entity attributes.

get_validated_dict

def get_validated_dict(json_str: Text) -> Dict[Text, Text]

Converts the provided json_str to a valid dict containing the entity attributes.

Users can specify entity roles, synonyms, groups for an entity in a dict, e.g. [LA]{"entity": "city", "role": "to", "value": "Los Angeles"}.

Arguments:

  • json_str - The entity dict as string without "{}".

Raises:

SchemaValidationError if validation of parsed entity fails. InvalidEntityFormatException if provided entity is not valid json.

Returns:

Deserialized and validated json_str.

replace_entities

def replace_entities(training_example: Text) -> Text

Replace special symbols related to the entities in the provided training example.

Arguments:

  • training_example - Original training example with special symbols.

Returns:

String with removed special symbols.

parse_training_example

def parse_training_example(example: Text,
intent: Optional[Text] = None) -> "Message"

Extract entities and synonyms, and convert to plain text.