mtap.serialization

Serialization

MTAP input/output and serialization

class mtap.serialization.SerializationProcessor(*args, **kwargs)[source]

An MTAP EventProcessor that serializes events to a specific directory.

Parameters:
  • ser (Serializer) – The serializer to use.

  • output_dir (str) – The output_directory.

class mtap.serialization.Serializer[source]

Abstract base class for a serializer of MTAP events.

abstract property extension

Filename extension, including period. Ex: '.json'.

Type:

str

abstract event_to_file(event, f, *, include_label_text=False)[source]

Writes the event to a file.

Parameters:
  • event (Event) – The event object to serialize.

  • f (Union[Path, str, IOBase]) – A file or a path to a file to write the event to.

  • include_label_text (bool) – Whether, when serializing, to include the text that each label covers with the rest of the label.

abstract file_to_event(f, *, client=None)[source]

Loads an event from a serialized file.

Parameters:
Returns:

The loaded event object.

Return type:

Event