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: TypesBase[source]
property id: str[source]
is_document()[source]
is_type(at_type: str | TypesBase) 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 | None[source]

location property must be a legitimate URI. That is, should the document be a local file then the file:// scheme must be used. Returns None when no location is set.

location_address() str | None[source]

Retrieves the full address from the document location URI. Returns None when no location is set.

location_path() str | None[source]

Retrieves only path name of the document location (hostname is ignored). Useful to get a path of a local file. Returns None when no location is set.

location_scheme() str | None[source]

Retrieves URI scheme of the document location. Returns None when no location is set.

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 | None[source]

location property must be a legitimate URI. That is, should the document be a local file then the file:// scheme must be used. Returns None when no location is set.

location_address() str | None[source]

Retrieves the full address from the document location URI. Returns None when no location is set.

location_path() str | None[source]

Retrieves only path name of the document location (hostname is ignored). Useful to get a path of a local file. Returns None when no location is set.

location_scheme() str | None[source]

Retrieves URI scheme of the document location. Returns None when no location is set.

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]