You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ocrd-galley/ppn2ocr

89 lines
2.5 KiB
Plaintext

#!/bin/bash
# Get OCR results as a OCR-D workspace for a given PPN
set -e # Abort on error
show_help() {
cat <<-EOH
Usage: $0 PPN77164308X
Get OCR results as a OCR-D workspace for a given PPN
Options:
--help Show this message and exit.
EOH
}
make_workspace () {
ppn=$1
workspace=$2
# Make workspace directory
mkdir "$workspace"
cd "$workspace"
# Get METS from OAI-PMH
oai_identifier="oai%3Adigital.staatsbibliothek-berlin.de%3A$ppn"
oai_url="https://digital.staatsbibliothek-berlin.de/oai?verb=GetRecord&metadataPrefix=mets&identifier=$oai_identifier"
echo "$oai_url"
curl "$oai_url" | xmlstarlet sel -t -c '//*[local-name()="mets"]' > mets.xml
# Fix 'file:/' URLs to 'file:///'
sed -i 's#file:/\([^/]\)#file:///\1#' mets.xml
# Patch mets.xml to use our NFS mount
sed -i 's#file:///goobi/tiff001/sbb/#file:///srv/digisam_images/sbb/#g' mets.xml
# Remove LOCAL file group as we do not have access to the files
ocrd workspace remove-group -rf --keep-files LOCAL
# Validate workspace
ocrd workspace validate mets.xml | grep -v "<notice>Won't download remote image"
}
# Command line parameters
OPTS=`getopt -o h --long help -- "$@"`
eval set -- "$OPTS"
while true; do
case "$1" in
-h|--help) show_help; exit; shift;;
--) shift; break;;
*) break;;
esac
done
if [ -z "$1" ]; then show_help; exit; fi
ppn=$1
# From here, the magic happens
self_dir=`dirname $0`
self_dir=`realpath $self_dir`
make_workspace $ppn $ppn
$self_dir/run-docker-hub -I PRESENTATION --skip-validation
# TODO
# * README: Users must configure their proxy properly via environment variables;
# This includes setting no_proxy (e.g. for use at SBB).
# my_ocrd_workflow
# ----------------
# * Need option to add volumes e.g. /srv/digisam_images
# File bugs in OCR-D
# ------------------
# * <error>PAGE-XML OCR-D-IMG-BINPAGE/OCR-D-IMG-BINPAGE_0001.xml : imageFilename '/srv/digisam_images/sbb/PPN719671574/00000001.tif' not found in METS</error>
# -> had to use relative file names
# * Should be able to disable in workspace validate <notice>Won't download remote image <http://content.staatsbibliothek-berlin.de/dms/PPN719671574/800/0/00000335.jpg></notice>
# sbb_textline_detector
# ---------------------
# * sbb_textline_detector slow
# -> Support loading the models once so the OCR-D processor can profit from processing multiple pages
# * Check what happens with the skewed textlines in SEG_LINE_0019