Version: 3.x

rasa.shared.nlu.training_data.formats.readerwriter

TrainingDataReader Objects

class TrainingDataReader(abc.ABC)

Reader for NLU training data.

__init__

| __init__() -> None

Creates reader instance.

read

| read(filename: Union[Text, Path], **kwargs: Any) -> "TrainingData"

Reads TrainingData from a file.

reads

| @abc.abstractmethod
| reads(s: Text, **kwargs: Any) -> "TrainingData"

Reads TrainingData from a string.

TrainingDataWriter Objects

class TrainingDataWriter()

A class for writing training data to a file.

dump

| dump(filename: Text, training_data: "TrainingData") -> None

Writes a TrainingData object to a file.

dumps

| dumps(training_data: "TrainingData") -> Text

Turns TrainingData into a string.

prepare_training_examples

| @staticmethod
| prepare_training_examples(training_data: "TrainingData") -> Dict[Text, List[Union[Dict, Text]]]

Pre-processes training data examples by removing not trainable entities.

generate_list_item

| @staticmethod
| generate_list_item(text: Text) -> Text

Generates text for a list item.

generate_message

| @staticmethod
| generate_message(message: Dict[Text, Any]) -> Text

Generates text for a message object.

Arguments:

  • message - A message

Returns:

The text of the message, annotated with the entity data that is contained in the message

generate_entity_attributes

| @staticmethod
| generate_entity_attributes(text: Text, entity: Dict[Text, Any], short_allowed: bool = True) -> Text

Generates text for the entity attributes.

Arguments:

  • text - The text that is annotated with the entity
  • entity - Entity data
  • short_allowed - If True, allow shorthand annotation with parenthesis

Returns:

The annotation text that should follow the given text

generate_entity

| @staticmethod
| generate_entity(text: Text, entity: Union[Dict[Text, Any], List[Dict[Text, Any]]]) -> Text

Generates text for one or multiple entity objects.

Arguments:

  • text - The un-annotated text
  • entity - One or multiple entity annotations for one part of this text

Returns:

Annotated part of the text

JsonTrainingDataReader Objects

class JsonTrainingDataReader(TrainingDataReader)

A class for reading JSON files.

reads

| reads(s: Text, **kwargs: Any) -> "TrainingData"

Transforms string into json object and passes it on.

read_from_json

| read_from_json(js: Dict[Text, Any], **kwargs: Any) -> "TrainingData"

Reads TrainingData from a json object.