12
12
13
13
import cache
14
14
15
+ """
16
+ Helper function for showing debug information
17
+
18
+ def some_function(x):
19
+ from utils import app # import inside function
20
+ app.logger.debug(x)
21
+ """
15
22
16
23
class OCRFrame ():
17
24
"""
@@ -64,10 +71,10 @@ def add_bounding_box(self, anno, mmif):
64
71
else :
65
72
for alignment_anns in mmif .get_alignments (AnnotationTypes .BoundingBox , AnnotationTypes .TimePoint ).values ():
66
73
for alignment_ann in alignment_anns :
67
- if alignment_ann .get ('source' ) == anno .id :
74
+ if alignment_ann .get ('source' ) == anno .long_id :
68
75
timepoint_anno = mmif [alignment_ann .get ('target' )]
69
76
break
70
- elif alignment_ann .get ('target' ) == anno .id :
77
+ elif alignment_ann .get ('target' ) == anno .long_id :
71
78
timepoint_anno = mmif [alignment_ann .get ('source' )]
72
79
break
73
80
if timepoint_anno :
@@ -93,8 +100,7 @@ def add_timeframe(self, anno, mmif):
93
100
start_id , end_id = anno .properties .get (
94
101
"targets" )[0 ], anno .properties .get ("targets" )[- 1 ]
95
102
anno_parent = mmif .get_view_by_id (anno .parent )
96
- start_anno , end_anno = anno_parent .get_annotation_by_id (
97
- start_id ), anno_parent .get_annotation_by_id (end_id )
103
+ start_anno , end_anno = anno_parent .get_annotation_by_id (start_id ), anno_parent .get_annotation_by_id (end_id )
98
104
start = convert_timepoint (mmif , start_anno , "frames" )
99
105
end = convert_timepoint (mmif , end_anno , "frames" )
100
106
start_secs = convert_timepoint (mmif , start_anno , "seconds" )
@@ -163,6 +169,8 @@ def get_ocr_frames(view, mmif):
163
169
164
170
# Account for alignment in either direction
165
171
frame = OCRFrame (source , mmif )
172
+ if target .at_type == DocumentTypes .TextDocument :
173
+ frame .add_timepoint (source , mmif , skip_if_view_has_frames = False )
166
174
frame .update (target , mmif )
167
175
168
176
i = frame .frame_num if frame .frame_num is not None else frame .range
0 commit comments