Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
f930fbf9
Commit
f930fbf9
authored
6 years ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Fix bulk_transcriptions
parent
e32ecd01
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Add score to transcriptions
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/images/importer.py
+8
-8
8 additions, 8 deletions
arkindex/images/importer.py
with
8 additions
and
8 deletions
arkindex/images/importer.py
+
8
−
8
View file @
f930fbf9
...
...
@@ -8,6 +8,7 @@ import re
import
gzip
import
logging
import
fnmatch
import
uuid
REGEX_INDEX
=
re
.
compile
(
b
'
^(?:line_(\d+) )?(.+) \d+ ([\de\-\.]+) (\d+) (\d+) (\d+) (\d+)
'
)
...
...
@@ -93,13 +94,12 @@ def bulk_transcriptions(image, page, items):
# Build all TrBox from existing
existing
=
{
TrBox
(
BoundingBox
(
zone
.
polygon
),
BoundingBox
(
tr
.
zone
.
polygon
),
tr
.
line
,
tr
.
text
,
tr
.
score
,
)
for
tr
in
Transcription
.
objects
.
filter
(
zones__image
=
image
).
prefetch_related
(
'
zones
'
)
for
zone
in
tr
.
zones
.
all
()
for
tr
in
Transcription
.
objects
.
filter
(
zone__image
=
image
).
prefetch_related
(
'
zone
'
)
}
# Calc needed TrBox to build
...
...
@@ -111,7 +111,7 @@ def bulk_transcriptions(image, page, items):
# Raw elements
elements
=
Element
.
objects
.
bulk_create
(
Element
(
type
=
ElementType
.
Transcription
)
Element
(
type
=
ElementType
.
Transcription
,
zone_id
=
uuid
.
uuid4
()
)
for
_
in
needed
)
...
...
@@ -125,7 +125,7 @@ def bulk_transcriptions(image, page, items):
score
=
n
.
score
,
),
Zone
(
element_
id
=
elt
.
id
,
id
=
elt
.
zone_
id
,
image
=
image
,
polygon
=
n
.
box
.
to_polygon
(),
)
...
...
@@ -133,6 +133,9 @@ def bulk_transcriptions(image, page, items):
for
elt
,
n
in
zip
(
elements
,
needed
)
])
# Create zones in bulk
Zone
.
objects
.
bulk_create
(
zones
)
# Create transcriptions using a low-level bulk_create
# as multi table is not supported yet by Django
Transcription
.
objects
.
none
().
_batched_insert
(
...
...
@@ -145,9 +148,6 @@ def bulk_transcriptions(image, page, items):
batch_size
=
None
,
)
# Create zones in bulk
Zone
.
objects
.
bulk_create
(
zones
)
# Create all links between transcription and page
max_order_dl
=
ElementLink
.
objects
.
filter
(
parent
=
page
).
order_by
(
'
-order
'
).
first
()
max_order
=
0
if
max_order_dl
is
None
else
max_order_dl
.
order
+
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment