Skip to content

Commit

Permalink
Try bulk creating annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed Jan 26, 2024
1 parent e5b12a9 commit 1c49cb9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions readux_ingest_ecds/services/ocr_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def parse_xml_ocr(result):

def add_ocr_annotations(canvas, ocr):
word_order = 1
annotations = []
for word in ocr:
print(f'adding word {word}')
# A quick check to make sure the header row didn't slip through.
Expand All @@ -400,11 +401,13 @@ def add_ocr_annotations(canvas, ocr):
anno.resource_type = anno.OCR
anno.content = word['content']
anno.order = word_order
print(f'saving {word}')
anno.save()
print(f'saved {word}')
print(f'pushing {word}')
annotations.append(anno)
word_order += 1

print('saving')
OCR.bulk_create(annotations)

def add_oa_annotations(annotation_list_url):
data = fetch_url(annotation_list_url)
for oa_annotation in data['resources']:
Expand Down

0 comments on commit 1c49cb9

Please sign in to comment.