Annotation#
- class Annotation(annotation_data, page_file_path, plain_text, project, context=50)#
Bases:
objectClass which represents a CATMA annotation.
- Parameters
annotation_data (dict) – The annotation data as a dict.
page_file_path (str) – The path of the JSON annotation page file from which annotation_data was loaded.
plain_text (str) – The plain text annotated by the annotation.
project (CatmaProject) – The parent CatmaProject.
context (int, optional) – Size of the context that gets included in the data frame representation of annotation collections. Defaults to 50.
- project#
The parent CatmaProject
- data: dict#
The annotation in its json representation as a dict
- page_file_path: str#
The path of the annotation page file that this annotation was loaded from
- uuid: str#
The annotation’s uuid.
- date: datetime.datetime#
The date & time the annotation was created.
- author: str#
The annotation’s author.
- start_point: int#
The annotation’s start point (character index) in the plain text.
- end_point: int#
The annotation’s end point (character index) in the plain text.
- text: str#
The annotated text span.
- pretext: str#
The annotation’s left context.
- posttext: str#
The annotation’s right context.
- selectors: List[gitma.selector.Selector]#
The annotation’s selectors as a list of gitma.Selector
- tag#
The annotation’s tag as a gitma.Tag object.
- properties#
The annotation’s properties as a dictionary with property names as keys and the property values as list.
- to_dict()#
Returns annotation core elements as keys
- Returns
Annotation text, the tag, the properties as dictionary, start point and end point.
- Return type
dict
- remove()#
Removes the annotation from the annotation collection’s json file.
- modify_annotation()#
Overwrite annotation collection’s json file with the updated annotation data:
self.data.
- modify_start_point(new_start_point, relative=False)#
Rewrites annotation json file with new start point.
- Parameters
new_start_point (int) – New start point.
relative (bool, optional) – If true the
new_start_pointparameter is interpreted as relative to the old start point. Defaults to False.
- modify_end_point(new_end_point, relative=False)#
Rewrites annotation json file with new end point.
- Parameters
new_end_point (int) – New end point.
relative (bool, optional) – If true the
new_end_pointparameter is interpreted as relative to the old end point. Defaults to False.
- modify_property_value(tag, prop, old_value, new_value)#
Modifies property value if the annotation is tagged by defined tag and property by rewriting the annotation’s JSON file.
- Parameters
tag (str) – The annotation’s tag.
prop (str) – The tag property to be modified.
old_value (str) – The old property value.
new_value (str) – The new property value.
- set_property_values(tag, prop, value)#
Set property value of the given tag.
- Parameters
tag (str) – The tag’s name.
prop (str) – The property’s name.
value (list) – The list of new property values.
- delete_property(tag, prop)#
Deletes property if the annotation is tagged by defined tag and property.
- Parameters
tag (str) – The tag with the property to be deleted.
prop (str) – The property to be deleted.
- copy(annotation_collection_name, compare_annotation=None)#
Copies this annotation into another annotation collection, giving it a new UUID.
- Parameters
annotation_collection_name (str) – The name of the annotation collection that the annotation should be copied to.
compare_annotation (Annotation, optional) – An annotation to compare property values (for gold annotations). Defaults to None.