-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-samples.sh
executable file
·95 lines (67 loc) · 1.71 KB
/
run-samples.sh
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#! /bin/bash
#
THIS_SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SAMPLEDIR=${THIS_SCRIPT_DIR}/samples
OUTDIR=${SAMPLEDIR}/augmented
FONTMAP=$(randeli config get --key=policy.font-map-file)
if [ ! -r "${FONTMAP}" ]
then
echo "Missing fonts.json. Have you generated it ? (i.e. randeli map-fonts)"
exit 1
fi
mkdir -p ${OUTDIR}
ARGS="--font-map-file ${FONTMAP}"
function augment_pdf()
{
dir=$1
for pdf in $dir/*.pdf
do
echo "=> Augmenting $pdf"
base=$(basename $pdf)
args=""
if [ "${base}" == "uspto.8539484.pdf" ]
then
args="--ocr"
fi
if [ "${base}" == "mixed.pdf" ]
then
args="--ocr --ocr-mode element --ocr-dpi 96"
fi
# try this???
if [ "${dir}" == "xelatex" ]
then
args="--ocr --ocr-mode page --force-ocr --override policy.strong_box_height=0.6"
fi
echo randeli $ARGS augment --read $pdf --write ${OUTDIR}/$pdf $args
randeli $ARGS augment --read $pdf --write ${OUTDIR}/$pdf $args
echo "<="
echo ""
done
}
function augment_epub()
{
dir=$1
for epub in $dir/*.epub
do
echo "=> Augmenting $epub"
base=$(basename $epub)
args=""
echo randeli $ARGS augment --read $epub --write ${OUTDIR}/$epub $args
randeli $ARGS augment --read $epub --write ${OUTDIR}/$epub $args
echo "<="
echo ""
done
}
(
cd ${SAMPLEDIR}
for dir in 3rdParty pdflatex xelatex
do
mkdir -p ${OUTDIR}/$dir
augment_pdf $dir
done
for dir in 3rdParty epub
do
mkdir -p ${OUTDIR}/$dir
augment_epub $dir
done
)