mirror of
https://github.com/mikegerber/ocrd_calamari.git
synced 2025-06-09 11:49:53 +02:00
smoke test, circle ci
Conflicts: Makefile ocrd_calamari/__init__.py
This commit is contained in:
parent
afe6eec5a2
commit
b54ccf90f7
8 changed files with 167 additions and 18 deletions
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
10
test/base.py
Normal file
10
test/base.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
# pylint: disable=unused-import
|
||||
|
||||
import os
|
||||
import sys
|
||||
from unittest import TestCase, skip, main # pylint: disable=unused-import
|
||||
|
||||
from test.assets import assets
|
||||
|
||||
PWD = os.path.dirname(os.path.realpath(__file__))
|
||||
sys.path.append(PWD + '/../ocrd')
|
62
test/test_recognize.py
Normal file
62
test/test_recognize.py
Normal file
|
@ -0,0 +1,62 @@
|
|||
import os
|
||||
from os.path import join, exists
|
||||
import shutil
|
||||
|
||||
from test.base import TestCase, main, assets, skip
|
||||
|
||||
from ocrd.resolver import Resolver
|
||||
|
||||
from ocrd_tesserocr import TesserocrSegmentRegion
|
||||
from ocrd_tesserocr import TesserocrSegmentLine
|
||||
|
||||
from ocrd_calamari import CalamariRecognize
|
||||
|
||||
#METS_HEROLD_SMALL = assets.url_of('SBB0000F29300010000/data/mets_one_file.xml')
|
||||
# as long as #96 remains, we cannot use workspaces which have local relative files:
|
||||
METS_HEROLD_SMALL = assets.url_of('kant_aufklaerung_1784-binarized/data/mets.xml')
|
||||
|
||||
WORKSPACE_DIR = '/tmp/test-ocrd-calamari'
|
||||
|
||||
class TestCalamariRecognize(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
if exists(WORKSPACE_DIR):
|
||||
shutil.rmtree(WORKSPACE_DIR)
|
||||
os.makedirs(WORKSPACE_DIR)
|
||||
|
||||
#skip("Takes too long")
|
||||
def runTest(self):
|
||||
resolver = Resolver()
|
||||
workspace = resolver.workspace_from_url(METS_HEROLD_SMALL, dst_dir=WORKSPACE_DIR)
|
||||
|
||||
TesserocrSegmentRegion(
|
||||
workspace,
|
||||
input_file_grp="OCR-D-IMG",
|
||||
output_file_grp="OCR-D-SEG-BLOCK"
|
||||
).process()
|
||||
workspace.save_mets()
|
||||
|
||||
TesserocrSegmentLine(
|
||||
workspace,
|
||||
input_file_grp="OCR-D-SEG-BLOCK",
|
||||
output_file_grp="OCR-D-SEG-LINE"
|
||||
).process()
|
||||
workspace.save_mets()
|
||||
|
||||
CalamariRecognize(
|
||||
workspace,
|
||||
input_file_grp="OCR-D-SEG-LINE",
|
||||
output_file_grp="OCR-D-OCR-CALAMARI",
|
||||
parameter={
|
||||
'checkpoint': 'calamari_models/fraktur_historical/*.ckpt.json'
|
||||
}
|
||||
).process()
|
||||
workspace.save_mets()
|
||||
|
||||
page1 = join(workspace.directory, 'OCR-D-OCR-CALAMARI/OCR-D-OCR-CALAMARI_0001.xml')
|
||||
self.assertTrue(exists(page1))
|
||||
with open(page1, 'r') as f:
|
||||
self.assertIn('verſchuldeten', f.read())
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue