Skip to content

Commit c1a10e5

Browse files
Merge pull request #42 from clamsproject/PaddleOCR-refined
Paddle ocr refined
2 parents 6778625 + 664b895 commit c1a10e5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ocr.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212

1313
import cache
1414

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+
"""
1522

1623
class OCRFrame():
1724
"""
@@ -64,10 +71,10 @@ def add_bounding_box(self, anno, mmif):
6471
else:
6572
for alignment_anns in mmif.get_alignments(AnnotationTypes.BoundingBox, AnnotationTypes.TimePoint).values():
6673
for alignment_ann in alignment_anns:
67-
if alignment_ann.get('source') == anno.id:
74+
if alignment_ann.get('source') == anno.long_id:
6875
timepoint_anno = mmif[alignment_ann.get('target')]
6976
break
70-
elif alignment_ann.get('target') == anno.id:
77+
elif alignment_ann.get('target') == anno.long_id:
7178
timepoint_anno = mmif[alignment_ann.get('source')]
7279
break
7380
if timepoint_anno:
@@ -93,8 +100,7 @@ def add_timeframe(self, anno, mmif):
93100
start_id, end_id = anno.properties.get(
94101
"targets")[0], anno.properties.get("targets")[-1]
95102
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)
98104
start = convert_timepoint(mmif, start_anno, "frames")
99105
end = convert_timepoint(mmif, end_anno, "frames")
100106
start_secs = convert_timepoint(mmif, start_anno, "seconds")
@@ -163,6 +169,8 @@ def get_ocr_frames(view, mmif):
163169

164170
# Account for alignment in either direction
165171
frame = OCRFrame(source, mmif)
172+
if target.at_type == DocumentTypes.TextDocument:
173+
frame.add_timepoint(source, mmif, skip_if_view_has_frames=False)
166174
frame.update(target, mmif)
167175

168176
i = frame.frame_num if frame.frame_num is not None else frame.range

0 commit comments

Comments
 (0)