#! /bin/csh -f # Last edited on 2000-02-04 16:12:59 by stolfi set usage = "$0 FILE1.frq FILE2.prb > OUTFILE.pr2" # Joins two word probability files (with lines of the form PROB WORD) # inserting proper defaults. Writes lines of the form PROB1 PROB2 WORD. if ( $#argv != 2) then echo "usage: ${usage}"; exit 1 endif set filea = "$1"; shift; set fileb = "$1"; shift; set tmp = "/tmp/$$" sort -b +1 -2 ${filea} > ${tmp}-a.prb sort -b +1 -2 ${fileb} > ${tmp}-b.prb /n/gnu/bin/join \ -j1 2 -j2 2 -o '1.1,2.1,0' \ -a1 -a2 -e 0.00000 \ ${tmp}-a.prb ${tmp}-b.prb \ | gawk '/./{printf "%7.5f %s %s %s\n", $1+$2, $1, $2, $3;}' \ | sort -b +0 -1gr +3 -4 \ | gawk '/./{print $2, $3, $4;}' /bin/rm -f ${tmp}-*.prb