add tests (#18)

* add tests

* add sentencepiece dependency
This commit is contained in:
Maciej Budyś
2022-11-03 21:01:36 +01:00
committed by GitHub
parent 71fe10621a
commit 6309289958
18 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import json
from pathlib import Path
from tqdm import tqdm
from manga_ocr import MangaOcr
TEST_DATA_ROOT = Path(__file__).parent / 'data'
def generate_expected_results():
mocr = MangaOcr()
results = []
for path in tqdm(sorted((TEST_DATA_ROOT / 'images').iterdir())):
result = mocr(path)
results.append({'filename': path.name, 'result': result})
(TEST_DATA_ROOT / 'expected_results.json').write_text(json.dumps(results, ensure_ascii=False, indent=2),
encoding='utf-8')
if __name__ == '__main__':
generate_expected_results()