Skip to content

Commit 281e2cd

Browse files
committed
minor updates in docstring
1 parent ec053fa commit 281e2cd

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

mmif/serialize/annotation.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,24 +75,32 @@ def _deserialize(self, input_dict: dict) -> None:
7575

7676
def _cache_alignment(self, alignment_ann: 'Annotation', alignedto_ann: 'Annotation') -> None:
7777
"""
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)
8282
"""
8383
self._alignments[alignment_ann] = alignedto_ann
8484

8585
def aligned_to_by(self, alignment: 'Annotation') -> Optional['Annotation']:
8686
"""
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``.
8992
"""
9093
return self._alignments.get(alignment)
9194

9295
def get_all_aligned(self) -> Iterator['Annotation']:
9396
"""
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
96104
"""
97105
for alignment, aligned in self._alignments.items():
98106
yield alignment
@@ -193,6 +201,7 @@ def add_property(self, name: str,
193201
value: Union[PRMTV_TYPES, LIST_PRMTV, LIST_LIST_PRMTV, DICT_PRMTV, DICT_LIST_PRMTV]) -> None:
194202
"""
195203
Adds a property to the annotation's properties.
204+
196205
:param name: the name of the property
197206
:param value: the property's desired value
198207
:return: None

0 commit comments

Comments
 (0)