#!/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 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; 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) update=yes; shift 1; ;; --thin) thin=yes; shift 1; ;; --compress) compress=yes; shift 1; ;; --drop) drop=yes; shift 1; ;; --compare) compare=yes; shift 1; ;; -f|--filter) filter=true; 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; ;; -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; ;; -d|--debug) debug=true; shift 1; ;; esac done if [ -n "${ascii}" ]; then skeleton="${LOGONROOT}/ntnu/data/mrs.txt"; unset compare; 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 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; { 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; \ 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 :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))"; 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 target=$(cat ${tmp}); 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))))"; fi; # # 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 :cpu :kill)"; if [ -n "${compare}" -a -n "${gold}" ]; then case ${grammar} in norgram) compare=":readings"; subsetp=nil; ;; erg|terg) compare=":readings :derivation"; subsetp=t; ;; gg) compare=":readings"; subsetp=nil; ;; jacy) compare=":readings"; subsetp=nil; ;; srg) compare=":readings"; subsetp=nil; ;; esac echo "(tsdb::compare-in-detail \"${gold}\" target :show '(:i-input) :compare '(${compare}) :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 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* \"mrs::get-mrs-string\")"; echo "(setf tsdb::*redwoods-thinning-normalize-p* t)"; 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} { 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}" ]; then ${LOGONROOT}/lingo/lkb/src/tsdb/home/itsdb --compress ${target}; if [ -n "${thin}" ]; then ${LOGONROOT}/lingo/lkb/src/tsdb/home/itsdb --compress ${target}.1; fi fi if [ -n "${thin}" -a -n "${drop}" ]; 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;