142 lines
3.1 KiB
Bash
142 lines
3.1 KiB
Bash
#!/bin/bash
|
|
# Usage: sequencelogic-run-scorewalker.sh [--timeout seconds] [--pkgname pkgname] [--out {outputpath}] --frt {frtfilepath} --libindex {libraryindexpath}
|
|
# Where:
|
|
# {frtfilepath} is the .frt file resulting from OCR
|
|
# {libraryindexpath} is the library index directory that enumerates the entire classification library
|
|
# {outputpath} is the optional output pathname; default is {frtfileparentpath}/classify.json
|
|
|
|
function usage(){
|
|
echo "Usage: $0 [--timeout seconds] [--pkgname pkgname] [--out {outputpath}] --frt {frtfilepath} --libindex {libraryindexpath} --config {library config file}"
|
|
echo " The --timeout arg option is used only for Linux"
|
|
echo " --pkgname pkgname argument is unused for $0."
|
|
exit 1
|
|
}
|
|
THREAD_COUNT=8
|
|
# setup
|
|
REDIR=/dev/null # use /dev/tty for debug
|
|
SCRIPT=$0
|
|
echo "[OK] Script: ${SCRIPT}" > ${REDIR}
|
|
# Absolute path this script is in, thus /home/user/bin
|
|
SCRIPTPATH=`dirname ${SCRIPT}`
|
|
echo "[OK] This script is located at: $SCRIPTPATH" > ${REDIR}
|
|
|
|
IPADDR=`hostname -i`
|
|
echo "The address of this host is: $IPADDR"
|
|
echo " --------- Memory Info ----------- "
|
|
free -m
|
|
uptime
|
|
echo ""
|
|
|
|
|
|
|
|
if [ -f "${SCRIPTPATH}/sequencelogic-helpers.sh" ]; then
|
|
source ${SCRIPTPATH}/sequencelogic-helpers.sh > ${REDIR}
|
|
else
|
|
source ${SEQUENCELOGICHOME}/bin/sequencelogic-helpers.sh > ${REDIR}
|
|
fi
|
|
|
|
# args
|
|
OUT=""
|
|
STAT=0
|
|
FRT=""
|
|
LIB=""
|
|
CONFIG=""
|
|
TIMEOUTPROG=""
|
|
|
|
if [ "$PLATFORM" = "Darwin" ]; then
|
|
function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
|
|
fi
|
|
|
|
if [ "$1" = "--timeout" ]; then
|
|
shift
|
|
TIMEOUTPROG="timeout $1"
|
|
shift
|
|
fi
|
|
|
|
if [ "$1" = "--pkgname" ]; then
|
|
shift
|
|
#CNAME="$1" Package name isn't needed!
|
|
shift
|
|
fi
|
|
|
|
if [ "$1" = "--out" ]; then
|
|
shift
|
|
OUT="$1"
|
|
shift
|
|
fi
|
|
|
|
if [ "$1" != "--frt" ]; then
|
|
echo "The --frt {frtpath} arg is required"
|
|
usage;
|
|
exit 1;
|
|
else
|
|
shift
|
|
FRT="$1"
|
|
shift
|
|
fi
|
|
|
|
if [ "$1" != "--libindex" ]; then
|
|
echo "The --libindex {indexfile} arg is required"
|
|
usage;
|
|
exit 1;
|
|
else
|
|
shift
|
|
LIB="$1"
|
|
shift
|
|
fi
|
|
|
|
if [ "$1" != "--config" ]; then
|
|
echo "The --config {lib config file} arg is required"
|
|
usage;
|
|
exit 1;
|
|
else
|
|
shift
|
|
CONFIG="$1"
|
|
shift
|
|
fi
|
|
|
|
if [ ! -f "${FRT}" ]; then
|
|
echo "--frt ${FRT} does not exist"
|
|
usage
|
|
exit 2;
|
|
fi
|
|
|
|
if [ ! -d "${LIB}" ]; then
|
|
echo "--libindex directory ${LIB} does not exist"
|
|
usage
|
|
exit 2;
|
|
fi
|
|
|
|
if [ "$OUT" = "" ]; then
|
|
OUT=`dirname "${FRT}"`/classify.json
|
|
fi
|
|
|
|
JAR=./target/walker-classifier-one-jar.jar
|
|
|
|
if [ -d "${LIB}/FirstPageIndex" ]
|
|
then
|
|
UseFirstPages="TRUE"
|
|
else
|
|
UseFirstPages="FALSE"
|
|
fi
|
|
|
|
MainClass=com.sequencelogic.walkerclassifier.WalkerClassifier
|
|
|
|
if [ "${SEQUENCELOGICHOME}" = "" ]; then
|
|
SEQUENCELOGICHOME=/sequencelogic
|
|
fi
|
|
|
|
if [ ! -f "${JAR}" ]; then
|
|
JAR="${SEQUENCELOGICHOME}/bin/walker-classifier-one-jar.jar"
|
|
fi
|
|
|
|
ram="4096m"
|
|
stack="128m"
|
|
$TIMEOUTPROG python3 "${SEQUENCELOGICHOME}/bin/sequencelogic-run-walker-classifier.py" --pkg-path "${FRT}" --index-root "${LIB}" --config "${CONFIG}" --out "${OUT}" 2>&1
|
|
# $TIMEOUTPROG java -Xms${stack} -Xmx${ram} -Done-jar.main.class=${MainClass} -jar ${JAR} -indexDir "${LIB}" -packageFile "${FRT}" -destDir "${OUT}" --configFile "${CONFIG}" 2>&1
|
|
|
|
exitStatus=${PIPESTATUS[0]}
|
|
|
|
echo "Exit with status: $exitStatus"
|
|
exit ${exitStatus}
|