#!/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"); count=1; limit=500; best=500; quantum=nil; protocol=1; time=nil; memory=nil; edges=nil; size=nil; source="--source"; grammar="erg"; client="erg+tnt"; features=""; while [ $# -gt 0 -a "${1#-}" != "$1" ]; do case ${1} in --binary) source=""; shift 1; ;; --source) source="--source"; shift 1; ;; --client) client=${2}; shift 2; ;; --norgram) grammar=norgram; client=norgram; shift 1; ;; --erg) grammar=erg; client=cheap; shift 1; ;; --erg*|--mrs) grammar=erg; client=${1##--}; shift 1; ;; --terg*) grammar=terg; client=${1##--}; shift 1; ;; --deepbank*) grammar=deepbank; client=${1##--}; shift 1; ;; --gg*) grammar=gg; client=${1##--}; shift 1; ;; --jacy*) grammar=jacy; client=${1##--}; shift 1; ;; --srg*) grammar=srg; client=${1##--}; shift 1; ;; --cheetah*) grammar=cheetah; client=${1##--}; shift 1; ;; --krg) grammar=krg; client=krg@pet; shift 1; ;; --classic) mode="classic"; shift 1; ;; --modern) mode="modern"; shift 1; ;; --target) target="${2}"; shift 2; ;; -g|--gold) gold="${2}"; shift 2; ;; -u|--update*) if [ "${1}" != "${1%%/s*}" ]; then update=skeptical; elif [ "${1}" != "${1%%/external*}" ]; then update=external; else update=yes; fi shift 1; ;; --thin*) thin=yes; trees="lkb::extract-syntax-tree"; semantics="mrs::get-mrs-string"; 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 shift 1; ;; --compress) compress=yes; shift 1; ;; --drop) drop=yes; shift 1; ;; --compare) if [ "${2}" = "magic" ]; then compare="${2}"; else if [ "${compare}" = "magic" ]; then unset compare; fi tmp="${LOGONTMP}/.parse.${USER}.io.$$"; echo "${2}" | sed 's/,/\n/g' > ${tmp}; while read i; do compare="${compare} :${i}"; done < ${tmp}; /bin/rm -f ${tmp} > /dev/null 2>&1; fi shift 2; ;; --decorate) tmp="${LOGONTMP}/.parse.${USER}.io.$$"; echo "${2}" | sed 's/,/\n/g' > ${tmp}; while read i; do decorate="${decorate} :${i}"; done < ${tmp}; /bin/rm -f ${tmp} > /dev/null 2>&1; shift 2; ;; -f|--filter) filter=yes; shift 1; ;; --export) export=true; shift 1; ;; -c|--count) count=${2}; shift 2; ;; -l|--limit) limit=${2}; shift 2; ;; -b|--best) best=${2}; if [ "${best}" != "0" -a "${limit}" != "0" ]; then limit=${best}; fi shift 2; ;; --time) time=${2}; if [ -n "$(echo ${time} | sed 's/[0-9]*//')" ]; then echo "parse: invalid time limit \`${time}'; exit."; exit 1; fi if [ "${quantum}" = "nil" ]; then quantum=$[$time + $[$time / 10]]; fi shift 2; ;; --memory) memory=${2}; if [ -n "$(echo ${memory} | sed 's/[0-9]*//')" ]; then echo "parse: invalid memory limit \`${memory}'; exit."; exit 1; fi shift 2; ;; --edges) edges=${2}; if [ -n "$(echo ${edges} | sed 's/[0-9]*//')" ]; then echo "parse: invalid edge limit \`${edges}'; exit."; exit 1; fi shift 2; ;; --size) size=${2}; if [ -n "$(echo ${size} | sed 's/[0-9]*//')" ]; then echo "parse: invalid process size limit \`${size}'; exit."; exit 1; fi shift 2; ;; --quantum) quantum="${2}"; shift 2; ;; --protocol) protocol="${2}"; shift 2; ;; --lexical) lexical=yes; shift 1; ;; -a|--text|--bitext|--ascii) ascii=true; shift 1; ;; -s|--suffix) suffix="${2}"; shift 2; ;; --seconds) shift 1; date=$(date "+%y-%m-%d.%H:%M:%S"); ;; --cat) cat="--cat"; shift 1; ;; --gc) gc=yes; shift 1; ;; --reset) reset=yes; shift 1; ;; --features) features="${features},${2}"; shift 2; ;; --prologue) prologue=${2}; shift 2; ;; --epilogue) epilogue=${2}; shift 2; ;; -d|--debug) debug=true; shift 1; ;; *) echo "parse: invalid option \`${1}'; exit."; exit 1; ;; esac done if [ -n "${ascii}" ]; then skeleton="${LOGONROOT}/uio/wesearch/esd.txt"; else skeleton="esd"; fi if [ ! -z "${1}" ]; then skeleton=${1}; fi if [ -n "${ascii}" ]; then if [ "${skeleton#/}" = "${skeleton}" ]; then skeleton=${PWD}/${skeleton}; fi if [ ! -f "${skeleton}" ]; then echo "parse: unable to open \`${skeleton}'; exit."; exit 1; fi fi name=$(basename ${skeleton} ".gz"); name=$(basename ${name} ".txt"); name=$(basename ${name} ".gml"); name=$(basename ${name} ".yy"); if [ -z "${gold}" ]; then gold="gold/${grammar}/${skeleton}"; fi if [ -n "${compare}" -a -z "${decorate}" ]; then decorate=":readings :total"; fi if [ -z "${suffix}" -a -n "${lexical}" ]; then suffix=".l"; fi case ${client} in */speech*) features="${features},speech"; ;; esac if [ -z "${LOGONLOG}" ]; then LOGONLOG=${LOGONROOT}/log; fi LOG=${LOGONLOG}/${name}.parse.${date}.log; if [ "$filter" ]; then filter=${name}.parse.${date}.filter; fi tmp=$LOGONTMP/.parse.tmp.${USER}.$$; /bin/rm -f ${tmp} > /dev/null 2>&1; if [ -n "${reset}" ]; then reset; fi { options=":error :exit :wait 300"; echo "(setf (system:getenv \"DISPLAY\") nil)"; loadup; if [ -n "${gc}" ]; then gc; fi # # with these large images, try to tame incremental heap size growth rates # echo "(setf (sys:gsgc-parameter :expansion-free-percent-new) 5)"; echo "(setf (sys:gsgc-parameter :free-percent-new) 2)"; echo "(setf (sys:gsgc-parameter :expansion-free-percent-old) 5)"; echo "(setf tsdb::*process-suppress-duplicates* nil)"; echo "(setf tsdb::*process-raw-print-trace-p* t)"; if [ "${limit}" != "nil" ]; then echo "(setf tsdb::*tsdb-maximal-number-of-results* ${limit})"; fi; if [ -n "${best}" -a "${best}" != "0" ]; then echo "(setf tsdb::*tsdb-exhaustive-p* nil)"; if [ "${limit}" != "0" ]; then echo "(setf tsdb::*tsdb-maximal-number-of-analyses* ${best})"; fi fi; if [ -n "${lexical}" ]; then echo "(setf tsdb::*pvm-protocol* 33)"; else if [ "${protocol}" = "1" -o "${protocol}" = "2" ]; then echo "(setf tsdb::*pvm-protocol* ${protocol})"; fi fi case ${grammar} in norgram) skeletons="norsk"; ;; erg|terg) skeletons="english"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/lingo/${grammar}/lkb/script\")"; ;; 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 "parse: unable to locate DeepBank directory; exit."; exit 1; fi fi fi skeletons="english"; echo "(lkb::read-script-file-aux \"${DEEPBANK}/erg/lkb/script\")"; ;; gg) skeletons="deutsch"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/dfki/gg/lkb/script\")"; ;; jacy) echo "(tsdb:tsdb :skeletons \"${LOGONROOT}/dfki/jacy/tsdb/skeletons\")"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/dfki/jacy/lkb/script\")"; ;; srg) echo "(tsdb:tsdb :skeletons \"${LOGONROOT}/upf/srg/tsdb/skeletons\")"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/upf/srg/lkb/script\")"; ;; cheetah) skeletons="deutsch"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/coli/cheetah/lkb/script-dyn\")"; ;; krg) skeletons="hangul"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/khu/krg/lkb/script\")"; ;; esac if [ -n "${mode}" ]; then echo "(setf lkb::*tree-discriminants-mode* :${mode})"; fi if [ -n "${skeletons}" ]; then echo "(tsdb:tsdb :skeletons \"${LOGONROOT}/lingo/lkb/src/tsdb/skeletons/${skeletons}\")"; fi; # # communicate various resource limitations, if supplied, to [incr tsdb()] # if [ "${time}" != nil -o "${memory}" != nil \ -o "${edges}" != nil -o "${size}" != nil ]; then echo "(tsdb::enforce-limits :time ${time} :memory ${memory} :edges ${edges} :size ${size})"; fi # # launch one or more processing clients # echo "(tsdb:tsdb :cpu :${client} :task :parse :quantum ${quantum} :file t :count ${count} ${options})"; # # name and create the target profile, either from a skeleton or by means of # importing an ASCII input file # if [ -z "${target}" ]; then echo "(setf target (format nil \"~a~a\" (tsdb::suggest-test-run-directory \"${name}\" :absolute nil) \"${suffix}\"))" else echo "(setf target \"${target}\")"; fi if [ -z "${ascii}" ]; then echo "(tsdb:tsdb :create target :skeleton \"${name}\")" else echo "(tsdb::do-import-items \"${skeleton}\" target :format :ascii :create :purge)"; fi; # # to gain access to the actual profile name, we need to make Lisp write it # into a file, which means we need to wait until the Lisp sub-process has # caught up with us. this should complete in well under ten minutes. # echo "(with-open-file (stream \"${tmp}\" :direction :output :if-exists :supersede) (format stream \"~a~%\" target))"; echo "(sleep 2)"; if [ -z "${target}" ]; then i=0; while [ -z "${cat}" -a ${i} -lt 600 -a ! -s ${tmp} ]; do i=$[$i + 1]; sleep 1; done if [ ${i} -ge 600 ]; then echo "parse: failure to read \`target' profile name from Lisp; exit." exit 1; fi if [ -z "${cat}" ]; then target=$(cat ${tmp}); else target="target"; fi fi # # now that we know the name of the emerging new profile, compute the ‘gold’ # profile (e.g. for comparison) dynamically, if requested. # if [ -z "${cat}" -a "${gold}" = "magic" ]; then gold=$(echo "${target}" | sed "s/${suffix}\$//"); if [ "${gold}" = "${target}" ]; then unset gold; fi fi if [ -n "${debug}" ]; then echo "(setf tsdb::*tsdb-gc-verbosity* '(:stats))"; echo "(setf tsdb::*tsdb-gc-debug* (cons '((1 :new :zoom) (5 :old :room :zoom)) '((1 :new :old :holes :room))))"; echo "(setf tsdb::*tsdb-verbose-processing-p* t)"; echo "(setf tsdb::*pvm-debug-p* t)"; echo "(trace tsdb::flush-cache tsdb::complete_run)"; fi; epilogue; # # finally, send all items through our [incr tsdb()] client processor(s); once # processing completes, retire all processing clients to free up resources. # echo "(tsdb:tsdb :process target)" echo "(tsdb:tsdb :cpus :shutdown)"; subsetp=nil; if [ "${compare}" = "magic" -a -n "${gold}" ]; then case ${grammar} in norgram) compare=":readings"; ;; erg|terg|deepbank) compare=":readings :derivation"; subsetp=t; ;; gg) compare=":readings"; ;; jacy) compare=":readings"; ;; srg) compare=":readings"; ;; esac fi if [ -n "${compare}" -a -n "${gold}" ]; then echo "(tsdb::compare-in-detail \"${gold}\" target :show '(:i-input) :compare '(${compare}) :decorate '(${decorate}) :subsetp ${subsetp} :format :ascii)"; fi # # _fix_me_ # this seems incomplete; ‘--filter’ should take arguments, to select which # tests to apply, and we should decide whether or not to redirect outputs # into a separate file. (12-feb-03; oe) # if [ -n "${filter}" ]; then echo "(setf tsdb::*filter-test* '(:syntax :lnk :cscope :unet :fragmentation))"; echo "(tsdb::browse-results target :file \"/dev/null\")"; fi if [ -n "${gold}" -a -n "${update}" ]; then if [ -n "${lexical}" ]; then echo "(setf tsdb::*redwoods-update-exact-p* :inclusion)"; fi if [ "${update}" = "skeptical" ]; then echo "(setf lkb::*tree-skeptical-update-p* t)"; elif [ "${update}" = "external" ]; then echo "(setf lkb::*tree-display-view* :external)"; echo "(setf tsdb::*redwoods-treebanker-application* \"answer --annotate --${grammar}\")"; fi echo "(tsdb::purge-test-run target :action :tree)"; echo "(tsdb::purge-profile-cache target)"; echo "(setf lkb::*tree-automatic-update-p* t)"; echo "(tsdb::browse-trees target :interactive nil :gold \"${gold}\")"; fi if [ -n "${thin}" ]; then if [ "${thinning}" = ":tokenization" ]; then thinned="${target}.t"; elif [ "${thinning}" = ":top" ]; then thinned="${target}.p"; else thinned="${target}.1"; fi if [ -a $LOGONROOT/lingo/lkb/src/tsdb/home/${thinned} ]; then /bin/rm -rf $LOGONROOT/lingo/lkb/src/tsdb/home/${thinned}; fi echo "(setf tsdb::*redwoods-trees-hook* \"${trees}\")"; echo "(setf tsdb::*redwoods-semantix-hook* \"${semantics}\")"; echo "(setf tsdb::*redwoods-thinning-normalize-p* ${thinning})"; echo "(setf lkb::*tree-automatic-update-p* t)"; echo "(tsdb::browse-trees \"${target}\" :strip \"${thinned}\" :gold \"${gold}\")"; fi if [ -n "${export}" ]; then echo "(setf mrs::*eds-include-quantifiers-p* nil)"; echo "(setf mrs::*eds-include-vacuous-relations-p* nil)"; echo "(setf tsdb::*redwoods-export-values* '(:derivation :tree :avm :mrs :dependencies))"; echo "(setf tsdb::*redwoods-thinning-export-p* nil)"; echo "(tsdb::export-trees target :path \"${LOGONTMP}\")"; fi echo "(excl:exit)"; } | ${LOGONROOT}/bin/logon ${source} ${cat} \ -I base -locale no_NO.UTF-8 -qq 2>&1 | tee ${LOG} if [ $? -gt 0 ]; then exit $?; fi if [ -n "${cat}" ]; then exit 0; fi { if [ -z "${target}" ]; then target=$(cat ${tmp}); fi if [ -n "${target}" ]; then target=${LOGONROOT}/lingo/lkb/src/tsdb/home/${target}; gold=${LOGONROOT}/lingo/lkb/src/tsdb/home/${gold}; if [ -n "${compress}" -a -d ${target} ]; then ${LOGONROOT}/lingo/lkb/src/tsdb/home/itsdb --compress ${target}; if [ -n "${thin}" -a -d ${target}.1 ]; then ${LOGONROOT}/lingo/lkb/src/tsdb/home/itsdb --compress ${target}.1; fi fi if [ -n "${thin}" -a -n "${drop}" -a -d ${target}.1 ]; then echo $LOGONROOT/lingo/lkb/src/tsdb/home/itsdb \ --drop ${gold} ${target}.1; fi fi } 2>&1 | tee -a ${LOG} /bin/rm -f $tmp > /dev/null 2>&1;