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
9cf17c29
Commit
9cf17c29
authored
1 year ago
by
Solene Tarride
Committed by
Solene Tarride
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Update tests for data extraction
parent
bcfaa598
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
tests/test_extract.py
+28
-3
28 additions, 3 deletions
tests/test_extract.py
with
28 additions
and
3 deletions
tests/test_extract.py
+
28
−
3
View file @
9cf17c29
...
...
@@ -10,7 +10,12 @@ import pytest
from
dan.datasets.extract.exceptions
import
NoEndTokenError
from
dan.datasets.extract.extract
import
ArkindexExtractor
from
dan.datasets.extract.utils
import
EntityType
,
insert_token
,
remove_spaces
from
dan.datasets.extract.utils
import
(
EntityType
,
insert_token
,
normalize_linebreaks
,
normalize_spaces
,
)
from
dan.utils
import
parse_tokens
from
tests
import
FIXTURES
...
...
@@ -135,8 +140,25 @@ def test_reconstruct_text(entity_separators, tokens, expected, text_before, text
(
"
\t
tab
"
,
"
tab
"
),
),
)
def
test_remove_spaces
(
text
,
trimmed
):
assert
remove_spaces
(
text
)
==
trimmed
def
test_normalize_spaces
(
text
,
trimmed
):
assert
normalize_spaces
(
text
)
==
trimmed
@pytest.mark.parametrize
(
"
text,trimmed
"
,
(
(
"
no_linebreaks
"
,
"
no_linebreaks
"
),
(
"
\n
beginning
"
,
"
beginning
"
),
(
"
ending
\n
"
,
"
ending
"
),
(
"
\n
both
\n
"
,
"
both
"
),
(
"
\n\n\n
consecutive
"
,
"
consecutive
"
),
(
"
\r
carriage_return
"
,
"
carriage_return
"
),
(
"
\r\n
carriage_return+linebreak
"
,
"
carriage_return+linebreak
"
),
(
"
\n\r\r\n\n
carriage_return+linebreak
"
,
"
carriage_return+linebreak
"
),
),
)
def
test_normalize_linebreaks
(
text
,
trimmed
):
assert
normalize_linebreaks
(
text
)
==
trimmed
@pytest.mark.parametrize
(
...
...
@@ -306,6 +328,9 @@ def test_extract(
VAL_DIR
/
"
text_line_val-page_1-line_2.jpg
"
,
VAL_DIR
/
"
text_line_val-page_1-line_3.jpg
"
,
output
/
"
labels.json
"
,
output
/
"
language_corpus.txt
"
,
output
/
"
language_lexicon.txt
"
,
output
/
"
language_tokens.txt
"
,
]
assert
sorted
(
filter
(
methodcaller
(
"
is_file
"
),
output
.
rglob
(
"
*
"
)))
==
expected_paths
...
...
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