forked from cisocrgroup/ocrd_cis
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_lib.bash
51 lines (47 loc) · 1.46 KB
/
test_lib.bash
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
#/bin/bash
tmpdir=$(mktemp -d)
trap "rm -rf $tmpdir" EXIT
OCRD_CIS_FILEGRP="OCR-D-GT-SEG-LINE"
data_url="https://ocr-d-repo.scc.kit.edu/api/v1/dataresources/75ad9f94-dbaa-43e0-ab06-2ce24c497c61/data"
function ocrd_cis_download_bagit() {
local url="$data_url/$1"
mkdir -p "$tmpdir/download"
wget -P "$tmpdir/download" "$url"
}
function ocrd_cis_init_ws() {
ocrd_cis_download_bagit "$1"
ocrd zip spill -d "$tmpdir" "$tmpdir/download/$1"
tmpws="$tmpdir/${1%.ocrd.zip}"
}
function ocrd_cis_align() {
# download ocr models
wget -P "$tmpdir/download" "http://cis.lmu.de/~finkf/fraktur1-00085000.pyrnn.gz"
wget -P "$tmpdir/download" "http://cis.lmu.de/~finkf/fraktur2-00062000.pyrnn.gz"
# run ocr
ocrd-cis-ocropy-recognize --log-level DEBUG \
--input-file-grp "OCR-D-GT-SEG-LINE" \
--output-file-grp OCR-D-CIS-OCR-1 \
--mets "$tmpws/mets.xml" \
--parameter <(cat <<EOF
{
"textequiv_level": "word",
"model": "$tmpdir/download/fraktur1-00085000.pyrnn.gz"
}
EOF
)
ocrd-cis-ocropy-recognize --log-level DEBUG \
--input-file-grp "OCR-D-GT-SEG-LINE" \
--output-file-grp OCR-D-CIS-OCR-2 \
--mets "$tmpws/mets.xml" \
--parameter <(cat <<EOF
{
"textequiv_level": "word",
"model": "$tmpdir/download/fraktur2-00062000.pyrnn.gz"
}
EOF
)
ocrd-cis-align --log-level DEBUG \
-I OCR-D-CIS-OCR-1,OCR-D-CIS-OCR-2,OCR-D-GT-SEG-LINE \
-O OCR-D-CIS-ALIGN \
-m $tmpws/mets.xml
}