mmif.serialize module

mmif.serialize.model module

mmif.serialize.mmif module

mmif.serialize.view module

mmif.serialize.annotation module

The annotation module contains the classes used to represent a MMIF annotation as a live Python object.

In MMIF, annotations are created by apps in a pipeline as a part of a view. For documentation on how views are represented, see mmif.serialize.view.

class mmif.serialize.annotation.Annotation(anno_obj: bytes | str | dict | None = None)[source]

Bases: FreezableMmifObject

MmifObject that represents an annotation in a MMIF view.

add_property(name: str, value: str | int | float | bool | None | List[str | int | float | bool | None] | List[List[str | int | float | bool | None]]) None[source]

Adds a property to the annotation’s properties. :param name: the name of the property :param value: the property’s desired value :return: None

property at_type: str | ThingTypesBase[source]
property id: str[source]
is_document()[source]
is_type(type: str | ThingTypesBase) bool[source]

Check if the @type of this object matches.

class mmif.serialize.annotation.AnnotationProperties(mmif_obj: bytes | str | dict | None = None)[source]

Bases: FreezableMmifObject

AnnotationProperties object that represents the properties object within a MMIF annotation.

Parameters:

mmif_obj – the JSON data that defines the properties

class mmif.serialize.annotation.Document(doc_obj: bytes | str | dict | None = None)[source]

Bases: Annotation

Document object that represents a single document in a MMIF file.

A document is identified by an ID, and contains certain attributes and potentially contains the contents of the document itself, metadata about how the document was created, and/or a list of subdocuments grouped together logically.

If document_obj is not provided, an empty Document will be generated.

Parameters:

document_obj – the JSON data that defines the document

add_property(name: str, value: str | int | float | bool | None | List[str | int | float | bool | None]) None[source]

Adds a property to the annotation’s properties. :param name: the name of the property :param value: the property’s desired value :return: None

property location: str[source]
location_address() str[source]
location_path() str[source]
location_scheme() str[source]
property parent: str[source]
property text_language: str[source]
property text_value: str[source]
class mmif.serialize.annotation.DocumentProperties(mmif_obj: bytes | str | dict | None = None)[source]

Bases: AnnotationProperties

DocumentProperties object that represents the properties object within a MMIF document.

Parameters:

mmif_obj – the JSON data that defines the properties

property location: str[source]
location_address() str[source]
location_path() str[source]
location_scheme() str[source]
property text_language: str[source]
property text_value: str[source]
class mmif.serialize.annotation.Text(text_obj: bytes | str | dict | None = None)[source]

Bases: FreezableMmifObject

property lang: str[source]
property value: str[source]