#!/bin/bash unset TERM unset DISPLAY; unset LUI; if [ -z "${LOGONROOT}" ]; then # # determine the LOGON root directory, assuming this script resides in the # top-level 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}"; export LOGONROOT . ${LOGONROOT}/dot.bashrc fi # # include a shared set of shell functions and global parameters, including the # architecture identifier .LOGONOS. # . ${LOGONROOT}/etc/library.bash; date=$(date "+%y-%m-%d"); export=""; filter=""; increment=1000; source="--source"; active="t-active >= 1"; thinning="nil"; composite="nil"; index="nil"; blind="nil"; treebank=erg; features=""; trees="lkb::extract-syntax-tree"; semantics="mrs::get-mrs-string"; tsdb=${LOGONROOT}/bin/tsdb; while [ $# -gt 0 -a "${1#-}" != "$1" ]; do case ${1} in --binary) source=""; shift 1; ;; --source) source="--source"; shift 1; ;; --cat) cat=--cat; shift 1; ;; --export*) action=export; if [ "${1}" != "${1%%/*blind*}" ]; then blind="t"; fi if [ "${1}" != "${1%%/*id*}" ]; then lnk="id"; fi tmp="${LOGONTMP}/.redwoods.${USER}.io.$$"; echo "${2}" | sed 's/,/\n/g' > ${tmp}; while read i; do export="${export} :${i}"; done < ${tmp}; /bin/rm -f ${tmp} > /dev/null 2>&1; if [ -z "${target}" ]; then target=${LOGONROOT}/tmp; fi shift 2; ;; --run) action=run; shift 1; ;; --thin*) action=thin; if [ "${1}" != "${1%%/*top*}" ]; then thinning=":top"; elif [ "${1}" != "${1%%/*tokenization*}" ]; then thinning=":tokenization"; else thinning="t"; fi if [ "${1}" != "${1%%/*eds*}" ]; then semantics="mrs::get-eds-string"; fi if [ "${1}" != "${1%%/*blind*}" ]; then blind="t"; fi if [ "${1}" != "${1%%/*id*}" ]; then lnk="id"; fi shift 1; ;; --normalize*) action=normalize; thinning="nil"; semantics="nil"; shift 1; ;; --compress) compress=yes; shift 1; ;; --update) action=update; shift 1; ;; --filter) action=filter; tmp="${LOGONTMP}/.redwoods.${USER}.io.$$"; echo "${2}" | sed 's/,/\n/g' > ${tmp}; while read i; do filter="${filter} :${i}"; done < ${tmp}; /bin/rm -f ${tmp} > /dev/null 2>&1; shift 2; ;; --score) action=score; shift 1; ;; --gold) gold="${2}"; shift 2; ;; --erg*) treebank=erg; script=${LOGONROOT}/lingo/erg/lkb/script; home=${LOGONROOT}/lingo/erg/tsdb/gold; skeletons=${LOGONROOT}/lingo/lkb/src/tsdb/skeletons/english; case ${1} in */speech*) features="${features},speech"; ;; esac shift 1; ;; --terg*) treebank=terg; script=${LOGONROOT}/lingo/terg/lkb/script; home=${LOGONROOT}/lingo/terg/tsdb/gold; skeletons=${LOGONROOT}/lingo/lkb/src/tsdb/skeletons/english; case ${1} in */speech*) features="${features},speech"; ;; esac shift 1; ;; --redwoods*) treebank=redwoods; base=${LOGONROOT}/lingo/redwoods; script=${base}/erg/lkb/script; home=${base}/tsdb/home; skeletons=${LOGONROOT}/lingo/lkb/src/tsdb/skeletons/english; case ${1} in */speech*) features="${features},speech"; ;; esac shift 1; ;; --wikiwoods*) treebank=wikiwoods; script=${LOGONROOT}/lingo/erg/lkb/script; home=${LOGONROOT}/uio/wikiwoods/1212/tsdb; skeletons=${LOGONROOT}/lingo/lkb/src/tsdb/skeletons/english; shift 1; ;; --deepbank*) treebank=deepbank; if [ -z "${DEEPBANK}" ]; then if [ -d ${LOGONROOT}/coli/deepbank ]; then DEEPBANK=${LOGONROOT}/coli/deepbank; else if [ -d /norstore/project/ltr/DELPH-IN/DeepBank ]; then DEEPBANK=/norstore/project/ltr/DELPH-IN/DeepBank; else echo "redwoods: unable to locate DeepBank directory; exit."; exit 1; fi fi fi base=${DEEPBANK}; script=${base}/erg/lkb/script; home=${base}/tsdb/gold; skeletons=${LOGONROOT}/lingo/lkb/src/tsdb/skeletons/english; if [ "${1}" != "${1%%/*robust*}" ]; then robust="size"; home=${base}/tsdb/robust; fi shift 1; ;; --jacy) treebank=jacy; script=${LOGONROOT}/dfki/jacy/lkb/script; home=${LOGONROOT}/dfki/jacy/tsdb/gold; skeletons=${LOGONROOT}/dfki/jacy/tsdb/skeletons; shift 1; ;; --hinoki) treebank=hinoki; base=${LOGONROOT}/ntu/hinoki; script=${base}/jacy/lkb/script; home=${base}/tsdb/home; skeletons=${LOGONROOT}/dfki/jacy/tsdb/skeletons; shift 1; ;; --srg) treebank=srg; script=${LOGONROOT}/upf/srg/lkb/script; home=${LOGONROOT}/upf/srg/tsdb/gold; skeletons=${LOGONROOT}/upf/srg/tsdb/skeletons; shift 1; ;; --tibidabo) treebank=tibidabo; base=${LOGONROOT}/ub/tibidabo script=${LOGONROOT}/upf/srg/lkb/script; home=${base}/tsdb/home; skeletons=${LOGONROOT}/upf/srg/tsdb/skeletons; shift 1; ;; --bosque) treebank=bosque; base=${LOGONROOT}/upf/bosque script=${LOGONROOT}/upf/srg/lkb/script; home=${base}/tsdb/home; skeletons=${LOGONROOT}/upf/srg/tsdb/skeletons; shift 1; ;; --home) if [ "${2}" = "default" ]; then home=${LOGONROOT}/lingo/lkb/src/tsdb/home; else home=${2} fi if [ ! -d ${home} ]; then echo "redwoods: invalid database root \`${home}'; exit." exit 1; fi shift 2; ;; # # _fix_me_ # maybe deprecate the redudant ‘--default’ soon. (22-aug-13; oe) # --default) home=${LOGONROOT}/lingo/lkb/src/tsdb/home; shift 1; ;; --robust) robust=${2}; shift 2; ;; --increment) increment=${2}; if [ "${increment}" = "nil" -o "${increment}" = "none" ]; then unset increment; fi shift 2; ;; --percentile) percentile=${2}; shift 2; ;; --composite) composite="t"; shift 1; ;; --index) index="t"; shift 1; ;; --gc) gc=yes; shift 1; ;; --condition) extra=${2}; shift 2; ;; --active) case ${2} in all) unset active; ;; resolved) active="t-active == 1"; ;; reduced) active="t-active >= 1"; ;; esac shift 2; ;; --classic) mode="classic"; shift 1; ;; --modern) mode="modern"; shift 1; ;; --target) target=${2}; shift 2; ;; --features) features="${features},${2}"; shift 2; ;; --prologue) proloque=${2}; shift 2; ;; --epilogue) epilogue=${2}; shift 2; ;; *) echo "redwoods: invalid option \`${1}'; exit."; exit 1; ;; esac done if [ -z "${action}" ]; then if [ -n "${compress}" ]; then action="compress"; else echo "redwoods: no valid action selected'; exit."; fi fi if [ -n "${export}" ]; then export="(${export# })"; elif [ "${action}" = "export" ]; then export="(:input :derivation :mrs :eds :ltriples)"; fi if [ -n "${1}" ]; then profile=${1}; fi if [ -z "${LOGONLOG}" ]; then LOGONLOG=${LOGONROOT}/log; fi log=${LOGONLOG}/${treebank}.$(basename ${profile}).${action}.${date}.log; case "${action}" in export|normalize|thin|compress|filter) export TSDB_HOME=${home}/${profile} if ${tsdb} -verify -quiet; then : else echo "redwoods: invalid \`${treebank}' profile \`${profile}'; exit." exit 1; fi ;; esac if [ -n "${gold}" ]; then export TSDB_HOME=${home}/${gold} if ${tsdb} -verify -quiet; then : else echo "redwoods: invalid \`gold' profile \`${gold}'; exit." exit 1; fi fi case "${action}" in export) { if [ ! -d ${target} ]; then { /bin/rm -f ${target}; mkdir -p ${target}; } > /dev/null 2>&1; fi low=$(${tsdb} -query 'select i-id from item' | sort -n | head -1); all=$(${tsdb} -query 'select i-id from item' | sort -n | tail -1); while [ ${low} -le ${all} ]; do if [ -n "${composite}" -o -z "${increment}" ]; then high=$[${all} + 1]; else high=$[${low} + ${increment}]; fi echo; echo "exporting \`${1}' [$low -- $high]"; echo; condition="i-id >= ${low} && i-id < ${high} && readings >= 1"; if [ ! -z "${active}" ]; then condition="(${condition}) && (${active})"; fi if [ ! -z "${extra}" ]; then condition="(${condition}) && (${extra})"; fi low=${high}; { echo "(setf (system:getenv \"DISPLAY\") nil)"; loadup; if [ -n "${gc}" ]; then gc; fi echo "(lkb:read-script-file-aux \"${script}\")"; echo "(tsdb:tsdb :home \"${home}\")"; echo "(tsdb:tsdb :skeletons \"${skeletons}\")"; echo "(setf tsdb::*redwoods-export-values* '${export})"; echo "(setf tsdb::*redwoods-thinning-export-p* ${thinning})"; echo "(setf mrs::*eds-include-quantifiers-p* t)"; echo "(setf mrs::*eds-include-vacuous-relations-p* t)"; if [ -n "${robust}" ]; then echo "(setf tsdb::*derivations-reconstruct-robust-p* :${robust})"; fi if [ -n "${lnk}" ]; then echo "(setf mrs::*lnkp* :${lnk})"; fi if [ -n "${mode}" ]; then echo "(setf lkb::*tree-discriminants-mode* :${mode})"; fi epilogue; echo "(tsdb::export-trees \"${profile}\" :path \"${target}\" :condition \"${condition}\" :compositep ${composite} :blindp ${blind} :index ${index})"; echo "(excl:exit)"; } | ${LOGONROOT}/bin/logon ${source} ${cat} \ -I base -locale no_NO.UTF-8 -qq done } 2>&1 | tee ${log} if [ "${index}" != "nil" ]; then echo ${profile} >> ${target}/.index; fi ;; run) if [ -n "${base}" ]; then cd ${base}; fi { echo "(setf (system:getenv \"DISPLAY\") nil)"; loadup; if [ -n "${gc}" ]; then gc; fi echo "(lkb:read-script-file-aux \"${script}\")"; echo "(tsdb:tsdb :home \"${home}\")"; echo "(tsdb:tsdb :skeletons \"${skeletons}\")"; if [ -n "${increment}" ]; then echo "(setf tsdb::%redwoods-items-increment% ${increment})"; echo "(setf tsdb::%redwoods-items-percentile% nil)"; elif [ -n "${percentile}" ]; then echo "(setf tsdb::%redwoods-items-percentile% ${percentile})"; fi if [ -n "${robust}" ]; then echo "(setf tsdb::*derivations-reconstruct-robust-p* :${robust})"; fi if [ -n "${mode}" ]; then echo "(setf lkb::*tree-discriminants-mode* :${mode})"; fi epilogue; echo "(load \"${profile}\")"; \ echo "(excl:exit 0 :no-unwind t)"; } | ${LOGONROOT}/bin/logon ${source} ${cat} \ -I base -locale no_NO.UTF-8 -qq 2>&1 | tee ${log} ;; normalize|thin) # # erase the target directory, if need be, and invoke the normalizer # if [ -z "${target}" ]; then if [ "${thinning}" = ":tokenization" ]; then target="${profile}.t"; elif [ "${thinning}" = ":top" ]; then target="${profile}.p"; elif [ "${action}" = "normalize" ]; then target="${profile}.n"; else target="${profile}.1"; fi fi if [ -a ${home}/${target} ]; then /bin/rm -rf ${home}/${target}; fi if [ -n "${compress}" ]; then compress="${home}/${target}"; fi { echo "(setf (system:getenv \"DISPLAY\") nil)"; loadup; if [ -n "${gc}" ]; then gc; fi echo "(lkb:read-script-file-aux \"${script}\")"; echo "(tsdb:tsdb :home \"${home}\")"; echo "(tsdb:tsdb :skeletons \"${skeletons}\")"; echo "(setf tsdb::*redwoods-trees-hook* \"${trees}\")"; echo "(setf tsdb::*redwoods-semantix-hook* \"${semantics}\")"; echo "(setf tsdb::*redwoods-thinning-normalize-p* ${thinning})"; if [ -n "${robust}" ]; then echo "(setf tsdb::*derivations-reconstruct-robust-p* :${robust})"; fi if [ -n "${lnk}" ]; then echo "(setf mrs::*lnkp* :${lnk})"; fi if [ -n "${mode}" ]; then echo "(setf lkb::*tree-discriminants-mode* :${mode})"; fi epilogue; echo "(setf lkb::*tree-automatic-update-p* t)"; echo "(tsdb::browse-trees \"${profile}\" :strip \"${target}\" :gold \"${gold}\" :condition \"${extra}\" :blindp ${blind})"; echo "(excl:exit 0 :no-unwind t)"; } | ${LOGONROOT}/bin/logon ${source} ${cat} \ -I base -locale no_NO.UTF-8 -qq 2>&1 | tee ${log} ;; score) { echo "(setf (system:getenv \"DISPLAY\") nil)"; loadup; if [ -n "${gc}" ]; then gc; fi echo "(lkb:read-script-file-aux \"${script}\")"; echo "(tsdb:tsdb :home \"${home}\")"; echo "(tsdb:tsdb :skeletons \"${skeletons}\")"; echo "(setf tsdb::*redwoods-trees-hook* nil)"; echo "(setf tsdb::*redwoods-score-counts* '(:parseval))"; if [ -n "${mode}" ]; then echo "(setf lkb::*tree-discriminants-mode* :${mode})"; fi epilogue; echo "(install-gc-strategy nil :tenure nil)"; echo "(tsdb::analyze-scores \"${profile}\" \"${gold}\" :condition \"${extra}\" :scorep t :spartanp t :n 1 :test :id :loosep t :format :ascii)"; echo "(excl:exit 0 :no-unwind t)"; } | ${LOGONROOT}/bin/logon ${source} ${cat} \ -I oe -locale no_NO.UTF-8 -qq 2>&1 | tee ${log} ;; update) if [ -z "${gold}" ]; then echo "redwoods: \`--gold' argument required for update."; exit 1; fi { echo "(setf (system:getenv \"DISPLAY\") nil)"; loadup; if [ -n "${gc}" ]; then gc; fi echo "(lkb:read-script-file-aux \"${script}\")"; echo "(tsdb:tsdb :home \"${home}\")"; echo "(tsdb:tsdb :skeletons \"${skeletons}\")"; echo "(setf tsdb::*redwoods-trees-hook* nil)"; echo "(setf tsdb::*redwoods-semantix-hook* nil)"; echo "(setf tsdb::*redwoods-thinning-normalize-p* nil)"; if [ -n "${mode}" ]; then echo "(setf lkb::*tree-discriminants-mode* :${mode})"; fi epilogue; echo "(tsdb::purge-test-run \"${profile}\" :action :tree)"; echo "(setf lkb::*tree-automatic-update-p* t)"; echo "(tsdb::browse-trees \"${profile}\" :interactive nil :gold \"${gold}\")"; echo "(excl:exit 0 :no-unwind t)"; } | ${LOGONROOT}/bin/logon ${source} ${cat} \ -I base -locale no_NO.UTF-8 -qq 2>&1 | tee ${log} ;; filter) condition="readings >= 1"; if [ ! -z "${active}" ]; then condition="(${condition}) && (${active})"; fi if [ ! -z "${extra}" ]; then condition="(${condition}) && (${extra})"; fi { echo "(setf (system:getenv \"DISPLAY\") nil)"; loadup; if [ -n "${gc}" ]; then gc; fi echo "(lkb:read-script-file-aux \"${script}\")"; echo "(tsdb:tsdb :home \"${home}\")"; echo "(tsdb:tsdb :skeletons \"${skeletons}\")"; echo "(setf tsdb::*redwoods-trees-hook* nil)"; echo "(setf tsdb::*redwoods-semantix-hook* nil)"; echo "(setf tsdb::*filter-test* '(${filter}))"; if [ -n "${mode}" ]; then echo "(setf lkb::*tree-discriminants-mode* :${mode})"; fi epilogue; echo "(tsdb::analyze \"${profile}\" :condition \"${condition}\" :thorough '(:derivation :mrs :tree :surface) :filter t :extras t :message nil)"; echo "(excl:exit 0 :no-unwind t)"; } | ${LOGONROOT}/bin/logon ${source} ${cat} \ -I base -locale no_NO.UTF-8 -qq 2>&1 | tee ${log} ;; esac { if [ -z "${cat}" -a -d "${compress}" ]; then ${LOGONROOT}/lingo/lkb/src/tsdb/home/itsdb --compress ${compress}; fi } 2>&1 | tee -a ${log}