plan4dial.for_generating.parsers.parse_for_rasa

This module contains all the functions necessary to generate a NLU file that Rasa can use to extract intents and entities.

NOTE: We use a bare-bones specification so we rely on Rasa as little as possible (no roles, groups, stories, or anything too “Rasa-specific”).

Authors: - Rebecca De Venezia

Functions

make_nlu_file(loaded_yaml)

Generates the NLU configuration that Rasa requires to extract intents and entities.

_create_intent_example(extracted_value: str, entity: str, true_value: str | None = None) str[source]

Create an intent example according to the Rasa NLU format. Also accounts for synonyms/variations if specified, while mapping back to the “true” value that we want to set to.

Parameters:
  • extracted_value (str) – The value that was extracted.

  • entity (str) – The entity we are trying to extract.

  • true_value (str or None) – If we extracted a variation, this is the “true” value that we want to set the extraction to. Defaults to None, in which case we know that the true value was what was extracted.

Returns:

The intent example.

Return type:

str

make_nlu_file(loaded_yaml: Dict) Dict[source]

Generates the NLU configuration that Rasa requires to extract intents and entities.

Parameters:

loaded_yaml (Dict) – The loaded YAML configuration.

Returns:

The NLU configuration for Rasa.

Return type:

Dict