#!/bin/bash if [ -z "${LOGONROOT}" ]; then # # determine the LOGON root directory, assuming this script resides in the # ‘bin/’ directory of the tree. # path=$(dirname $0) if [ "${path#./}" != "${path}" ]; then path="$(pwd)/${path#./}" fi if [ "${path#/}" = "${path}" ]; then if [ "${path}" = "." ]; then path="$(pwd)"; else path="$(pwd)/${path}" fi fi LOGONROOT="${path%/bin}"; export LOGONROOT fi if [ ! -f ${LOGONROOT}/dot.bashrc ]; then echo "epe: unable to determine \$LOGONROOT source directory; exit"; exit 1; fi . ${LOGONROOT}/dot.bashrc; while [ $# -gt 0 -a "${1#-}" != "$1" ]; do case ${1} in --32) LOGONOS=${LOGONOS%%.??}.32; shift 1; ;; --source) source="--source"; shift 1; ;; --binary) unset source; shift 1; ;; --cat) cat="--cat"; shift 1; ;; --gc) gc=yes; shift 1; ;; --convert) action=convert; shift 1; ;; --prepare) action=prepare; shift 1; ;; --project) action=project; shift 1; ;; --validate) action=validate; shift 1; ;; --raw) raw=$2; shift 2; ;; --gold) gold=$2; shift 2; ;; --from) from=$2; shift 2; ;; --to) to=$2; shift 2; ;; *) echo "epe: invalid option \`${1}'; exit."; exit 1; ;; esac done if [ ${action} = "convert" -a $# -ne 2 ]; then echo "usage: epe --convert [ --raw file ] [ --from format ] [ --to format ] /input/ /output/"; exit 1; fi if [ ${action} = "prepare" -a $# -ne 2 ]; then echo "usage: epe --prepare /input/ /output/"; exit 1; fi if [ ${action} = "project" -a $# -ne 2 ]; then echo "usage: epe --project --gold /gold/ /input/ /output/"; exit 1; fi if [ ${action} = "validate" -a $# -ne 1 ]; then echo "usage: epe --validate /input/"; exit 1; fi input=${1}; output=${2}; log=epe.${HOSTNAME}.$(date "+%Y-%m-%d-%H:%M:%S"); if [ -d ${LOGONLOG} ]; then log=${LOGONLOG}/${log}; fi if [ ${action} = "convert" ]; then if [ -z "${from}" -a -n "${input}" ]; then from=${input##*.}; fi if [ "${from}" = "conllx" -o "${from}" = "conll09" ]; then from="conll"; fi if [ -z "${to}" -a -n "${output}" ]; then to=${output##*.}; fi if [ -z "${from}" -o -z "${to}" ]; then echo "epe: unknown input or output format; exit."; exit 1; fi if [ -z "${input}" ]; then input="-"; fi if [ -z "${output}" ]; then output="-"; fi fi unset DISPLAY; { if [ -n "${source}" ]; then echo "(pushnew :lkb *features*)"; echo "(pushnew :logon *features*)"; echo "(load \"${LOGONROOT}/lingo/lkb/src/general/loadup.lisp\")"; echo "(compile-system \"tsdb\")"; fi if [ -n "${gc}" ]; then echo "(setf tsdb::*tsdb-gc-verbosity* '(:stats))"; echo "(setf tsdb::*tsdb-gc-debug* (cons '((1 :new) (5 :old :room)) '((1 :new :old :holes :room))))"; fi case ${action} in convert) echo "(tsdb::conll-convert \"${input}\" \"${output}\" :raw \"${raw}\" :from :${from} :to :${to})"; ;; prepare) echo "(tsdb::epe-preprocess \"${input}\" \"${output}\")"; ;; project) echo "(tsdb::epe-project \"${input}\" \"${gold}\" \"${output}\")"; ;; validate) output=${input%%.epe}.log; echo "(tsdb::read-epe \"${input}\" :debug \"${output}\")"; if [ -e ${output} -a ! -s ${output} ]; then /bin/rm -f ${output}; fi ;; esac echo "(excl:exit 0 :no-unwind t)"; } | $LOGONROOT/bin/logon ${source} ${cat} \ -I base -locale en_US.UTF-8 -qq \ -e "(setf excl:*print-startup-message* nil)" -qq 1>&1 | tee ${log}