mirror of
https://github.com/qurator-spk/dinglehopper.git
synced 2025-06-09 20:00:01 +02:00
✔ Properly test line dir finding
This commit is contained in:
parent
322faeb26c
commit
3b16c14c16
16 changed files with 18 additions and 23 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -25,6 +25,7 @@ dmypy.json
|
|||
|
||||
# User-specific stuff
|
||||
.idea
|
||||
.*.swp
|
||||
|
||||
# Build artifacts
|
||||
/build
|
||||
|
|
|
@ -1,29 +1,30 @@
|
|||
import os.path
|
||||
import itertools
|
||||
from typing import Iterator, Tuple
|
||||
import os
|
||||
|
||||
from ..cli_line_dirs import find_gt_and_ocr_files, find_gt_and_ocr_files_autodetect
|
||||
|
||||
data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")
|
||||
|
||||
|
||||
def test_basic():
|
||||
"""Test the dumb method: User gives directories and suffixes."""
|
||||
pairs = list(
|
||||
find_gt_and_ocr_files(
|
||||
"line_dirs_test/basic/gt",
|
||||
os.path.join(data_dir, "line_dirs/basic/gt"),
|
||||
".gt.txt",
|
||||
"line_dirs_test/basic/ocr",
|
||||
os.path.join(data_dir, "line_dirs/basic/ocr"),
|
||||
".some-ocr.txt",
|
||||
)
|
||||
)
|
||||
|
||||
assert len(pairs) == 2
|
||||
|
||||
|
||||
def test_basic_autodetect():
|
||||
"""Test the autodetect method: User gives directories, suffixes are autodetected if possible"""
|
||||
"""Test autodetect: User gives directories, suffixes are autodetected if possible"""
|
||||
pairs = list(
|
||||
find_gt_and_ocr_files_autodetect(
|
||||
"line_dirs_test/basic/gt",
|
||||
"line_dirs_test/basic/ocr",
|
||||
os.path.join(data_dir, "line_dirs/basic/gt"),
|
||||
os.path.join(data_dir, "line_dirs/basic/ocr"),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -34,9 +35,9 @@ def test_subdirs():
|
|||
"""Test the dumb method: Should also work when subdirectories are involved."""
|
||||
pairs = list(
|
||||
find_gt_and_ocr_files(
|
||||
"line_dirs_test/subdirs/gt",
|
||||
os.path.join(data_dir, "line_dirs/subdirs/gt"),
|
||||
".gt.txt",
|
||||
"line_dirs_test/subdirs/ocr",
|
||||
os.path.join(data_dir, "line_dirs/subdirs/ocr"),
|
||||
".some-ocr.txt",
|
||||
)
|
||||
)
|
||||
|
@ -48,30 +49,23 @@ def test_subdirs_autodetect():
|
|||
"""Test the autodetect method: Should also work when subdirectories are involved."""
|
||||
pairs = list(
|
||||
find_gt_and_ocr_files_autodetect(
|
||||
"line_dirs_test/subdirs/gt",
|
||||
"line_dirs_test/subdirs/ocr",
|
||||
os.path.join(data_dir, "line_dirs/subdirs/gt"),
|
||||
os.path.join(data_dir, "line_dirs/subdirs/ocr"),
|
||||
)
|
||||
)
|
||||
|
||||
assert len(pairs) == 2
|
||||
|
||||
|
||||
def test_merged():
|
||||
"""Test the dumb method: Should also work when GT and OCR texts are in the same directories."""
|
||||
"""Test the dumb method: GT and OCR texts are in the same directories."""
|
||||
pairs = list(
|
||||
find_gt_and_ocr_files(
|
||||
"line_dirs_test/merged",
|
||||
os.path.join(data_dir, "line_dirs/merged"),
|
||||
".gt.txt",
|
||||
"line_dirs_test/merged",
|
||||
os.path.join(data_dir, "line_dirs/merged"),
|
||||
".some-ocr.txt",
|
||||
)
|
||||
)
|
||||
|
||||
assert len(pairs) == 2
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_basic()
|
||||
test_subdirs()
|
||||
test_merged()
|
||||
|
||||
test_basic_autodetect()
|
||||
test_subdirs_autodetect()
|
Loading…
Add table
Add a link
Reference in a new issue