#!/bin/bash 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=1000; best=1000; quantum=nil; source="--source"; grammar="norgram"; client="norgram"; 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; ;; --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; ;; --target) target="${2}"; shift 2; ;; -g|--gold) gold="${2}"; shift 2; ;; -u|--update*) if [ "${1}" != "${1%%/s*}" ]; then update=sketical; else update=yes; fi shift 1; ;; --thin*) thin=yes; semantics="mrs::get-mrs-string"; if [ "${1}" != "${1%%/*top*}" ]; then thinning=":top"; 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" ]; then limit=${best}; fi shift 2; ;; --quantum) quantum="${2}"; shift 2; ;; --lexical) lexical=yes; shift 1; ;; -a|--text|--bitext|--ascii) ascii=true; shift 1; ;; -s|--suffix) suffix="${2}"; shift 2; ;; --time) 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; ;; --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}/ntnu/data/mrs.txt"; else skeleton="mrs"; 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 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 name=$(basename ${skeleton} ".txt"); 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"; 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" -a "${limit}" != "0" ]; 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)"; echo "(setf tsdb::*tsdb-maximal-number-of-analyses* ${best})"; fi; if [ -n "${lexical}" ]; then echo "(setf tsdb::*pvm-protocol* 33)"; fi case ${grammar} in norgram) skeletons="norsk"; ;; erg|terg) skeletons="english"; case ${client} in */speech*) echo "(pushnew :speech *features*)"; ;; esac echo "(lkb::read-script-file-aux \"${LOGONROOT}/lingo/${grammar}/lkb/script\")"; echo "(setf tsdb::*tsdb-maximal-number-of-edges* 100000)"; ;; gg) skeletons="deutsch"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/dfki/gg/lkb/script\")"; echo "(setf tsdb::*tsdb-maximal-number-of-edges* 100000)"; ;; jacy) echo "(tsdb:tsdb :skeletons \"${LOGONROOT}/dfki/jacy/tsdb/skeletons\")"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/dfki/jacy/lkb/script\")"; echo "(setf tsdb::*tsdb-maximal-number-of-edges* 100000)"; ;; srg) echo "(tsdb:tsdb :skeletons \"${LOGONROOT}/upf/srg/tsdb/skeletons\")"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/upf/srg/lkb/script\")"; echo "(setf tsdb::*tsdb-maximal-number-of-edges* 100000)"; ;; cheetah) skeletons="deutsch"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/coli/cheetah/lkb/script-dyn\")"; echo "(setf tsdb::*tsdb-maximal-number-of-edges* 100000)"; ;; krg) skeletons="hangul"; echo "(lkb::read-script-file-aux \"${LOGONROOT}/khu/krg/lkb/script\")"; echo "(setf tsdb::*tsdb-maximal-number-of-edges* 100000)"; ;; esac if [ -n "${skeletons}" ]; then echo "(tsdb:tsdb :skeletons \"${LOGONROOT}/lingo/lkb/src/tsdb/skeletons/${skeletons}\")"; 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 iput 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) (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 [ "${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 the 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) 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 if [ -n "${filter}" ]; then echo "(setf tsdb::*filter-test* '(:syntax :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)"; fi echo "(tsdb::purge-test-run target :action :tree)"; echo "(tsdb::purge-profile-cache target)"; echo "(tsdb::browse-trees target :interactive nil :gold \"${gold}\")"; fi if [ -n "${thin}" ]; then thinned="${target}.1"; 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* nil)"; echo "(setf tsdb::*redwoods-semantix-hook* \"${semantics}\")"; echo "(setf tsdb::*redwoods-thinning-normalize-p* ${thinning})"; echo "(tsdb::browse-trees \"${target}\" :strip \"${thinned}\")"; 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 { target=$(cat ${tmp}); 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;