@@ -51,22 +51,22 @@ def update(self, anno, mmif):
51
51
52
52
elif anno .at_type .shortname == "Paragraph" :
53
53
view = mmif .get_view_by_id (anno .parent )
54
- text_anno = view . get_annotation_by_id ( anno .properties .get ("document" ))
54
+ text_anno = mmif [ anno .properties .get ("document" )]
55
55
self .add_text_document (text_anno )
56
56
57
57
def add_bounding_box (self , anno , mmif : Mmif ):
58
58
timepoint_anno = None
59
59
if "timePoint" in anno .properties :
60
- timepoint_anno = find_annotation ( anno .get ("timePoint" ), mmif )
60
+ timepoint_anno = mmif [ anno .get ("timePoint" )]
61
61
62
62
else :
63
63
for alignment_anns in mmif .get_alignments (AnnotationTypes .BoundingBox , AnnotationTypes .TimePoint ).values ():
64
64
for alignment_ann in alignment_anns :
65
65
if alignment_ann .get ('source' ) == anno .id :
66
- timepoint_anno = find_annotation ( alignment_ann .get ('target' ), mmif )
66
+ timepoint_anno = mmif [ alignment_ann .get ('target' )]
67
67
break
68
68
elif alignment_ann .get ('target' ) == anno .id :
69
- timepoint_anno = find_annotation ( alignment_ann .get ('source' ), mmif )
69
+ timepoint_anno = mmif [ alignment_ann .get ('source' )]
70
70
break
71
71
if timepoint_anno :
72
72
self .add_timepoint (timepoint_anno , mmif , skip_if_view_has_frames = False )
@@ -90,7 +90,7 @@ def add_timeframe(self, anno, mmif):
90
90
if "targets" in anno .properties :
91
91
start_id , end_id = anno .properties .get ("targets" )[0 ], anno .properties .get ("targets" )[- 1 ]
92
92
anno_parent = mmif .get_view_by_id (anno .parent )
93
- start_anno , end_anno = anno_parent . get_annotation_by_id ( start_id ), anno_parent . get_annotation_by_id ( end_id )
93
+ start_anno , end_anno = mmif [ start_id ], mmif [ end_id ]
94
94
start = convert_timepoint (mmif , start_anno , "frames" )
95
95
end = convert_timepoint (mmif , end_anno , "frames" )
96
96
start_secs = convert_timepoint (mmif , start_anno , "seconds" )
@@ -126,16 +126,6 @@ def add_text_document(self, anno):
126
126
text_val = re .sub (r'([\\\/\|\"\'])' , r'\1 ' , t )
127
127
self .text = self .text + [text_val ] if text_val not in self .text else self .text
128
128
129
- def find_annotation (anno_id , mmif ):
130
- if mmif .id_delimiter in anno_id :
131
- view_id , anno_id = anno_id .split (mmif .id_delimiter )
132
- view = mmif .get_view_by_id (view_id )
133
- for view in mmif .views :
134
- try :
135
- return view .get_annotation_by_id (anno_id )
136
- except KeyError :
137
- continue
138
-
139
129
140
130
def get_ocr_frames (view , mmif ):
141
131
frames = {}
@@ -144,8 +134,8 @@ def get_ocr_frames(view, mmif):
144
134
# If view contains alignments
145
135
if full_alignment_type :
146
136
for alignment in view .get_annotations (full_alignment_type [0 ]):
147
- source = find_annotation ( alignment .get ("source" ), mmif )
148
- target = find_annotation ( alignment .get ("target" ), mmif )
137
+ source = mmif [ alignment .get ("source" )]
138
+ target = mmif [ alignment .get ("target" )]
149
139
150
140
# Account for alignment in either direction
151
141
frame = OCRFrame (source , mmif )
0 commit comments