You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a app developer, I would like to have the superpower to navigate Alignment annotations and their arguments (target, source) more easily, instead of writing complicated graph building code every time I have to deal with alignments like
Add a hidden (ignored-when-serialized) attribute to each mmif.serialize.annotation.Annotation instance to hold a dict from Alignment object long_id to the counter part object long_id. For example, supposed that we have three annotation objects in a MMIF
When de-serialized, the annotation object will have hidden attributes to "cache" aligned annotation ids.
>>>m=Mmif(mmif_str)
>>>m.get('v_0:to_1')._alignments
{"v_0:al_2": "v_0:tf_1"}
>>>m.get('v_0:tf_1')._alignments
{"v_0:al_2": "v_0:to_1"}
>>>m.get('v_0:al_1')._alignments
{} # unless alignment annotation itself is aligned to other annotations
If there are multiple alignments to an annotation, the dict simply needs to be extended with more. Updating the _alignments attribute (tentative name) should be added to
Currently View object doesn't have access to its "parent" Mmif object, so getting long_ids of annotation object might not be trivial, unless we add that pointer to the parent in the View class.
Related
No response
Alternatives
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
New Feature Summary
As a app developer, I would like to have the superpower to navigate
Alignment
annotations and their arguments (target
,source
) more easily, instead of writing complicated graph building code every time I have to deal with alignments likeand many more instances.
implementation proposal
Add a hidden (ignored-when-serialized) attribute to each
mmif.serialize.annotation.Annotation
instance to hold a dict fromAlignment
object long_id to the counter part object long_id. For example, supposed that we have three annotation objects in a MMIFWhen de-serialized, the annotation object will have hidden attributes to "cache" aligned annotation ids.
If there are multiple alignments to an annotation, the dict simply needs to be extended with more. Updating the
_alignments
attribute (tentative name) should be added tommif-python/mmif/serialize/mmif.py
Line 189 in 90ec32f
View::add_annotation
method (mmif-python/mmif/serialize/view.py
Line 106 in 2a5bffc
View::new_annotation
method (mmif-python/mmif/serialize/view.py
Line 77 in 2a5bffc
limitation
Currently
View
object doesn't have access to its "parent"Mmif
object, so getting long_ids of annotation object might not be trivial, unless we add that pointer to the parent in theView
class.Related
No response
Alternatives
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: