medkit.core.attribute#

Classes#

Attribute

Medkit attribute, to be added to an annotation.

Module Contents#

class medkit.core.attribute.Attribute(label: str, value: Any | None = None, metadata: dict[str, Any] | None = None, uid: str | None = None)#

Bases: medkit.core.dict_conv.SubclassMapping

Medkit attribute, to be added to an annotation.

Attributes:
label: str

The attribute label

value: Any, optional

The value of the attribute. Should be either simple built-in types (int, float, bool, str) or collections of these types (list, dict, tuple). If you need structured complex data you should create a subclass of Attribute.

metadata: dict of str to Any

The metadata of the attribute

uid: str

The identifier of the attribute

label: str#
value: Any | None#
metadata: dict[str, Any]#
uid: str#
classmethod __init_subclass__()#
to_dict() dict[str, Any]#
to_brat() Any | None#

Return a value compatible with the brat format.

to_spacy() Any | None#

Return a value compatible with spaCy.

copy() Attribute#

Create a copy of the attribute with a new identifier.

This is used when we want to duplicate an existing attribute onto a different annotation.

classmethod from_dict(attribute_dict: dict[str, Any]) typing_extensions.Self#

Create an Attribute from a dict.

Parameters:
attribute_dict: dict of str to Any

A dictionary from a serialized Attribute as generated by to_dict()