@@ -75,24 +75,32 @@ def _deserialize(self, input_dict: dict) -> None:
75
75
76
76
def _cache_alignment (self , alignment_ann : 'Annotation' , alignedto_ann : 'Annotation' ) -> None :
77
77
"""
78
- Cache alignment information. This cache will not be serialized. Both ID arguments must be in their long_id
79
- format.
80
- :param alignment_id: long_id of the Alignment annotation that has this annotation on one side
81
- :param alignedto_id: long_id of the annotation that this annotation is aligned to (other side of Alignment)
78
+ Cache alignment information. This cache will not be serialized.
79
+
80
+ :param alignment_ann: the Alignment annotation that has this annotation on one side
81
+ :param alignedto_ann: the annotation that this annotation is aligned to (other side of Alignment)
82
82
"""
83
83
self ._alignments [alignment_ann ] = alignedto_ann
84
84
85
85
def aligned_to_by (self , alignment : 'Annotation' ) -> Optional ['Annotation' ]:
86
86
"""
87
- Retrieve the long_id of the annotation that this annotation is aligned to.
88
- :param alignment: Alignment annotation that has this annotation on one side
87
+ Retrieves the other side of ``Alignment`` annotation that has this annotation on one side.
88
+
89
+ :param alignment: ``Alignment`` annotation that has this annotation on one side
90
+ :return: the annotation that this annotation is aligned to (other side of ``Alignment``),
91
+ or None if this annotation is not used in the ``Alignment``.
89
92
"""
90
93
return self ._alignments .get (alignment )
91
94
92
95
def get_all_aligned (self ) -> Iterator ['Annotation' ]:
93
96
"""
94
- Generator to iterate through all alignments and aligned annotations.
95
- :return: yields the alignment annotation and the aligned annotation in order
97
+ Generator to iterate through all alignments and aligned annotations. Note that this generator will yield
98
+ the `Alignment` annotations as well. Every odd-numbered yield will be an `Alignment` annotation, and every
99
+ even-numbered yield will be the aligned annotation. If there's a specific annotation type that you're looking
100
+ for, you need to filter the generated results outside.
101
+
102
+ :return: yields the alignment annotation and the aligned annotation.
103
+ The order is decided by the order of appearance of Alignment annotations in the MMIF
96
104
"""
97
105
for alignment , aligned in self ._alignments .items ():
98
106
yield alignment
@@ -193,6 +201,7 @@ def add_property(self, name: str,
193
201
value : Union [PRMTV_TYPES , LIST_PRMTV , LIST_LIST_PRMTV , DICT_PRMTV , DICT_LIST_PRMTV ]) -> None :
194
202
"""
195
203
Adds a property to the annotation's properties.
204
+
196
205
:param name: the name of the property
197
206
:param value: the property's desired value
198
207
:return: None
0 commit comments