#! /bin/csh -f
# Last edited on 2002-01-15 15:54:54 by stolfi

set cmd = "$0"; set cmd = "${cmd:t}"
set usage = "${cmd} LANG/BOOK SIZETAG"

if ( $#argv != 2 ) then
  echo "usage: ${usage}"; exit 1
endif

set sample = "$1"; shift;
set sizetag = "$1"; shift;

set lang = "${sample:h}"
set book = "${sample:t}"

echo "% Created `date '+%Y-%m-%d %H:%M:%S'` by ${cmd}"
echo "% "

set secs = ( `cat sample/${sample}/subsections-ok.tags` tot.t )
set secscm = "`echo ${secs} | tr ' ' ','`"

foreach sec ( ${secs} )
  set txsec = "`echo ${sec} | tr '.0123456789' 'PABCDEFGHIJ'`"
  set dir = "sample/${sample}/${sec}"
  foreach kind ( raw gud bad )
    set ntks = `cat ${dir}/${kind}.tks | wc -l`
    printf '\\def\\'"${lang}${book}${sizetag}${txsec}${kind}"'Tks{%d}\n' ${ntks}
    set nwds = `cat ${dir}/${kind}.wfr | wc -l`
    printf '\\def\\'"${lang}${book}${sizetag}${txsec}${kind}"'Wds{%d}\n' ${nwds}
  end
end
