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
4f880822
Commit
4f880822
authored
1 year ago
by
Eva Bardou
Committed by
Yoann Schneider
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow extracting elements holding transcriptions without entities
parent
2e719c9e
No related branches found
No related tags found
1 merge request
!348
Allow extracting elements holding transcriptions without entities
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dan/datasets/extract/arkindex.py
+5
-1
5 additions, 1 deletion
dan/datasets/extract/arkindex.py
tests/test_extract.py
+26
-0
26 additions, 0 deletions
tests/test_extract.py
with
31 additions
and
1 deletion
dan/datasets/extract/arkindex.py
+
5
−
1
View file @
4f880822
...
...
@@ -106,9 +106,10 @@ class ArkindexExtractor:
raise
NoTranscriptionError
(
element
.
id
)
transcription
=
random
.
choice
(
transcriptions
)
stripped_text
=
transcription
.
text
.
strip
()
if
not
self
.
tokens
:
return
transcription
.
text
.
strip
()
return
stripped_text
entities
=
get_transcription_entities
(
transcription
.
id
,
...
...
@@ -116,6 +117,9 @@ class ArkindexExtractor:
supported_types
=
list
(
self
.
tokens
),
)
if
not
entities
.
count
():
return
stripped_text
return
self
.
translate
(
entities_to_xml
(
transcription
.
text
,
entities
,
entity_separators
=
self
.
entity_separators
...
...
This diff is collapsed.
Click to expand it.
tests/test_extract.py
+
26
−
0
View file @
4f880822
...
...
@@ -425,6 +425,32 @@ def test_empty_transcription(allow_empty, mock_database):
extractor
.
extract_transcription
(
element_no_transcription
)
@pytest.mark.parametrize
(
"
tokens
"
,
(
None
,
EXTRACTION_DATA_PATH
/
"
tokens.yml
"
))
def
test_extract_transcription_no_translation
(
mock_database
,
tokens
):
extractor
=
ArkindexExtractor
(
element_type
=
[
"
text_line
"
],
entity_separators
=
None
,
tokens
=
tokens
,
)
element
=
Element
.
get_by_id
(
"
test-page_1-line_1
"
)
# Deleting one of the two transcriptions from the element
Transcription
.
get
(
Transcription
.
element
==
element
,
Transcription
.
worker_version_id
==
"
worker_version_id
"
,
).
delete_instance
(
recursive
=
True
)
# Deleting all entities on the element remaining transcription while leaving the transcription intact
if
tokens
:
TranscriptionEntity
.
delete
().
where
(
TranscriptionEntity
.
transcription
==
Transcription
.
select
().
where
(
Transcription
.
element
==
element
).
get
()
).
execute
()
# Early return with only the element transcription text instead of a translation
assert
extractor
.
extract_transcription
(
element
)
==
"
Coupez Bouis 7.12.14
"
@pytest.mark.parametrize
(
"
nestation, xml_output, separators
"
,
(
...
...
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