[go: up one dir, main page]

Menu

[r1]: / scripts / sigtest.sh  Maximize  Restore  History

Download this file

34 lines (27 with data), 867 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
SCR=${0##*/};
if [ $# -ne 2 ]; then echo "$SCR ref_file test_file"; exit 1; fi
export LC_ALL=C;
TMP=${TMPDIR:-/tmp}/$SCR.$$
trap "rm -rf $TMP* 2>/dev/null" EXIT
mkdir $TMP
ref=$1;
test=$2;
N=1000;
scoref=/home/jgonza/research/smt/evalMT/multi-bleu.perl;
for ((n=1;n<=N;n++)); do
cat $test | \
awk -v seed=$RANDOM -v ref=$ref -v tmp=$TMP '
BEGIN{while(getline<ref) refh[++nr]=$0;}
{testh[NR]=$0;}
END{srand(seed);
for(i=1;i<=NR;i++){
id=1+int(NR*rand());
printf "%s\n",testh[id] > tmp"/test";
printf "%s\n",refh[id] > tmp"/ref";}}'
$scoref $TMP/ref < $TMP/test >> $TMP/scoref;
done
sort -n -k 3 $TMP/scoref > $TMP/scoref.sorted;
lb=`cat $TMP/scoref.sorted | head -26 | tail -1 | awk '{print $3}'`;
ub=`cat $TMP/scoref.sorted | head -975 | tail -1 | awk '{print $3}'`;
echo "conf.int = [ $lb , $ub ]";