#!/bin/bash unset DISPLAY; unset LUI; gc() { 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 } # gc() if [ -z "${LOGONROOT}" ]; then echo "parse: unable to determine \$LOGONROOT directory; exit."; exit 1; 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"); action=export; export=""; increment=1000; source="--source"; target=${LOGONROOT}/tmp thinning="nil"; treebank=erg; tsdb=${LOGONROOT}/bin/tsdb; [ -d ${TARGET} ] || mkdir $TARGET; 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; tmp="/tmp/.redwoods.oe.io.$$"; echo "${2}" | sed 's/,/\n/g' > ${tmp}; while read i; do export="${export} :${i}"; done < ${tmp}; shift 2; ;; --fc) action=fc; shift 1; ;; --grid) action=grid; shift 1; ;; --train) action=train; shift 1; ;; --erg) treebank=erg; home=${LOGONROOT}/lingo/erg/tsdb/gold; script=${LOGONROOT}/lingo/erg/lkb/script; shift 1; ;; --redwoods) treebank=redwoods; home=${LOGONROOT}/lingo/redwoods/tsdb/home; script=${LOGONROOT}/lingo/redwoods/erg/lkb/script; shift 1; ;; --jacy) treebank=jacy; home=${LOGONROOT}/dfki/jacy/tsdb/gold; script=${LOGONROOT}/dfki/jacy/lkb/script; shift 1; ;; --hinoki) treebank=hinoki; home=${LOGONROOT}/ntu/hinoki/tsdb/home; script=${LOGONROOT}/ntu/hinoki/jacy/lkb/script; shift 1; ;; --increment) increment=${2}; shift 2; ;; --percentile) percentile=${2}; shift 2; ;; --gc) gc=yes; shift 1; ;; --thinning) thinning="t"; shift 1; ;; --condition) extra=${2}; shift 2; ;; --active) case ${2} in nil|null|all) unset active; ;; resolved) active="t-active == 1"; ;; reduced) active="t-active >= 1"; ;; esac shift 2; ;; *) echo "usage: redwoods [ options ] profile; exit."; exit 1; esac done if [ -n "${export}" ]; then export="(${export# })"; elif [ "${action}" = "export" ]; then export="(:derivation :mrs :dependencies)"; fi if [ -n "${1}" ]; then profile=${1}; fi if [ -z "${LOGONLOG}" ]; then LOGONLOG=${LOGONROOT}/log; fi log=${LOGONLOG}/${treebank}.${action}.${date}.log; case "${action}" in export) { export TSDB_HOME=${home}/${profile} if ${tsdb} -verify -quiet; then : else echo "redwoods: invalid \`${treebank}' profile \`${profile}'; exit." exit 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 high=$[${low} + ${increment}]; 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}; { loadup; gc; echo "(lkb:read-script-file-aux \"${script}\")"; echo "(tsdb:tsdb :home \"${home}\")"; 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* nil)"; echo "(tsdb::export-trees \"${profile}\" :path \"${target}\" :condition \"${condition}\")"; echo "(excl:exit)"; \ } | ${LOGONROOT}/bin/logon ${source} ${cat} \ -I base -locale no_NO.UTF-8 -qq done } 2>&1 | tee ${log} ;; fc) { loadup; gc; echo "(lkb:read-script-file-aux \"${script}\")"; 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 } | ${LOGONROOT}/bin/logon ${source} ${cat} \ -I base -locale no_NO.UTF-8 -qq 2>&1 | tee ${log} ;; esac