-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest_segment.py
59 lines (50 loc) · 2.09 KB
/
test_segment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# pylint: disable=import-error
import os
import shutil
from tests.base import TestCase, assets, main
from ocrd import Resolver
from ocrd_utils import initLogging, pushd_popd
from ocrd_kraken.segment import KrakenSegment
class TestKrakenSegment(TestCase):
def setUp(self):
initLogging()
def test_run_blla(self):
resolver = Resolver()
with pushd_popd(tempdir=True) as tempdir:
workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir, download=True)
proc = KrakenSegment(
workspace,
input_file_grp="OCR-D-IMG-BIN",
output_file_grp="OCR-D-SEG-LINE-KRAKEN",
parameter={'maxcolseps': 0, 'use_legacy': False}
)
proc.process()
workspace.save_mets()
def test_run_blla_regionlevel(self):
resolver = Resolver()
with pushd_popd(tempdir=True) as tempdir:
workspace = resolver.workspace_from_url(assets.path_to('kant_aufklaerung_1784-page-region/data/mets.xml'), dst_dir=tempdir, download=True)
proc = KrakenSegment(
workspace,
input_file_grp="OCR-D-GT-SEG-REGION",
output_file_grp="OCR-D-SEG-LINE-KRAKEN",
page_id="phys_0005",
parameter={'maxcolseps': 0, 'use_legacy': False}
)
proc.process()
workspace.save_mets()
def test_run_legacy(self):
resolver = Resolver()
# with pushd_popd('/tmp/kraken-test') as tempdir:
with pushd_popd(tempdir=True) as tempdir:
workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir, download=True)
proc = KrakenSegment(
workspace,
input_file_grp="OCR-D-IMG-BIN",
output_file_grp="OCR-D-SEG-LINE-KRAKEN",
parameter={'maxcolseps': 0, 'use_legacy': True}
)
proc.process()
workspace.save_mets()
if __name__ == "__main__":
main(__file__)