Skip to content

Commit

Permalink
Merge pull request #163 from bertsky/add-gcv-alto
Browse files Browse the repository at this point in the history
add PRImA converter for GCV→ALTO
  • Loading branch information
stweil authored Jun 9, 2023
2 parents 3e32ef6 + fee8f7b commit f7f7950
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ ocr-transform [OPTIONS] -L|--list List available from/to, and exit
alto4.2 alto2.1
alto page
alto text
gcv alto
gcv hocr
gcv page
hocr alto2.0
Expand Down Expand Up @@ -191,7 +192,7 @@ capable stylesheet transformer.
| ALTO ||||
| PAGEXML ||||
| FineReader || - ||
| Google Cloud Vision || - ||
| Google Cloud Vision || ||
| Amazon AWS Textract | - | - ||
| TEI || - | - |

Expand Down
32 changes: 32 additions & 0 deletions script/transform/gcv__alto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENDORDIR="$(cd $SCRIPTDIR/../../vendor/; pwd)"
JAR="$VENDORDIR/JPageConverter/PageConverter.jar"
INFILE="$1"
OUTFILE="$2"
ARGUMENT="$3"

if [[ "$1" = "-" ]]; then
INFILE="$(mktemp)"
cat >"$INFILE"
fi

if [[ "$2" = "-" ]]; then
OUTFILE="$(mktemp)"
fi

java -jar "$JAR" -neg-coords toZero -source-json "$INFILE" -target-xml "$OUTFILE" -convert-to ALTO 2>&1

if [[ "$1" = "-" ]]; then
rm "$INFILE"
fi

if [[ "$2" = "-" ]]; then
if [[ -z "$ARGUMENT" ]]; then
cat "$OUTFILE"
else
java -cp "$VENDORDIR/saxon.jar" net.sf.saxon.Query -s:"$OUTFILE" -qs:/ "$ARGUMENT"
fi
rm "$OUTFILE"
fi

0 comments on commit f7f7950

Please sign in to comment.