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
8bd5186f
Commit
8bd5186f
authored
1 year ago
by
Eva Bardou
Browse files
Options
Downloads
Patches
Plain Diff
Fix tests
parent
45ce3f9d
No related branches found
No related tags found
1 merge request
!348
Allow extracting elements holding transcriptions without entities
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_extract.py
+17
-18
17 additions, 18 deletions
tests/test_extract.py
with
17 additions
and
18 deletions
tests/test_extract.py
+
17
−
18
View file @
8bd5186f
...
...
@@ -425,30 +425,29 @@ def test_empty_transcription(allow_empty, mock_database):
extractor
.
extract_transcription
(
element_no_transcription
)
def
test_extract_transcription_no_tokens
(
mock_database
):
@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
,
# No tokens provided to the extractor
tokens
=
None
,
tokens
=
tokens
,
)
element
=
Element
.
get_by_id
(
"
test-page_1-line_1
"
)
assert
extractor
.
extract_transcription
(
element
)
==
"
Coupez Bouis 7.12.14
"
def
test_extract_transcription_without_entities
(
mock_database
):
extractor
=
ArkindexExtractor
(
element_type
=
[
"
text_line
"
],
entity_separators
=
None
,
tokens
=
EXTRACTION_DATA_PATH
/
"
tokens.yml
"
,
)
element
=
Element
.
get_by_id
(
"
test-page_1-line_1
"
)
# Deleting all entities on the element transcriptions while leaving the transcriptions intact
TranscriptionEntity
.
delete
().
where
(
TranscriptionEntity
.
transcription
.
in_
(
Transcription
.
select
().
where
(
Transcription
.
element
==
element
)
)
).
execute
()
# 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
"
...
...
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