Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DAN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Automatic Text Recognition
DAN
Commits
85deca6d
Commit
85deca6d
authored
2 years ago
by
Yoann Schneider
Browse files
Options
Downloads
Patches
Plain Diff
final touches
parent
58f3a2e3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dan/datasets/extract/extract_from_arkindex.py
+33
-30
33 additions, 30 deletions
dan/datasets/extract/extract_from_arkindex.py
with
33 additions
and
30 deletions
dan/datasets/extract/extract_from_arkindex.py
+
33
−
30
View file @
85deca6d
...
...
@@ -180,6 +180,37 @@ class ArkindexExtractor:
else
:
return
self
.
split_names
[
2
]
def
extract_entities
(
self
,
transcription
):
entities
=
self
.
client
.
request
(
"
ListTranscriptionEntities
"
,
id
=
transcription
[
"
id
"
],
worker_version
=
self
.
entity_worker_version
,
)
if
entities
[
"
count
"
]
==
0
:
logger
.
warning
(
f
"
No entities found on transcription (
{
transcription
[
'
id
'
]
}
).
"
)
return
else
:
text
=
transcription
[
"
text
"
]
count
=
0
for
entity
in
entities
[
"
results
"
]:
matching_tokens
=
self
.
tokens
[
entity
[
"
entity
"
][
"
metas
"
][
"
subtype
"
]]
start_token
,
end_token
=
(
matching_tokens
[
"
start
"
],
matching_tokens
[
"
end
"
],
)
text
,
count
=
insert_token
(
text
,
count
,
start_token
,
end_token
,
offset
=
entity
[
"
offset
"
],
length
=
entity
[
"
length
"
],
)
return
text
def
extract_transcription
(
self
,
element
,
...
...
@@ -198,37 +229,9 @@ class ArkindexExtractor:
transcription
=
transcriptions
[
"
results
"
].
pop
()
if
self
.
load_entities
:
entities
=
self
.
client
.
request
(
"
ListTranscriptionEntities
"
,
id
=
transcription
[
"
id
"
],
worker_version
=
self
.
entity_worker_version
,
)
if
entities
[
"
count
"
]
==
0
:
logger
.
warning
(
f
"
No entities found on transcription (
{
transcription
[
'
id
'
]
}
).
"
)
return
else
:
text
=
transcription
[
"
text
"
]
count
=
0
for
entity
in
entities
[
"
results
"
]:
matching_tokens
=
self
.
tokens
[
entity
[
"
entity
"
][
"
metas
"
][
"
subtype
"
]]
start_token
,
end_token
=
(
matching_tokens
[
"
start
"
],
matching_tokens
[
"
end
"
],
)
text
,
count
=
insert_token
(
text
,
count
,
start_token
,
end_token
,
offset
=
entity
[
"
offset
"
],
length
=
entity
[
"
length
"
],
)
return
self
.
extract_entities
(
transcription
)
else
:
text
=
transcription
[
"
text
"
].
strip
()
return
text
return
transcription
[
"
text
"
].
strip
()
def
process_element
(
self
,
...
...
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