File: regression-tests.sh

package info (click to toggle)
apertium-isl-eng 0.1.0~r66083-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 13,308 kB
  • sloc: xml: 24,392; sh: 329; makefile: 89
file content (57 lines) | stat: -rw-r--r-- 1,978 bytes parent folder | download | duplicates (3)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash

if [ -e /tmp/regression.src. ]; then
	rm /tmp/regression.src.;
fi

if [ -e /tmp/regression.trg. ]; then
	rm /tmp/regression.trg.;
fi

if [ -e /tmp/regression.tst. ]; then
	rm /tmp/regression.tst.;
fi

SRCLIST=`mktemp /tmp/regression.src.XXXXX`;
TRGLIST=`mktemp /tmp/regression.trg.XXXXX`;
TSTLIST=`mktemp /tmp/regression.tst.XXXXX`;

basedir=`pwd`;
mode=isl-eng

wget -O - -q http://wiki.apertium.org/wiki/Icelandic_and_English/Regression_tests | grep '<li>' | sed 's/<.*li>//g' | sed 's/ /_/g' | cut -f2 -d')' | sed 's/<i>//g' | sed 's/<\/i>//g' | cut -f2 -d'*' | sed 's/→/!/g' | cut -f1 -d'!' | sed 's/(note:/!/g' | sed 's/_/ /g' | sed 's/$/../g' > $SRCLIST;
wget -O - -q http://wiki.apertium.org/wiki/Icelandic_and_English/Regression_tests | grep '<li>' | sed 's/<.*li>//g' | sed 's/ /_/g' | sed 's/(\w\w)//g' | sed 's/<i>//g' | cut -f2 -d'*' | sed 's/<\/i>_→/!/g' | cut -f2 -d'!' | sed 's/_/ /g' | sed 's/^ *//g' | sed 's/ *$//g' | sed 's/$/../g' > $TRGLIST;

apertium -d . $mode < $SRCLIST > $TSTLIST;

cat $SRCLIST | sed 's/\.\.$//g' > $SRCLIST.n; mv $SRCLIST.n $SRCLIST;
cat $TRGLIST | sed 's/\.\.$//g' > $TRGLIST.n; mv $TRGLIST.n $TRGLIST;
cat $TSTLIST | sed 's/\.\.$//g' > $TSTLIST.n; mv $TSTLIST.n $TSTLIST;

TOTAL=0
CORRECT=0
for LINE in `paste -d'!' $SRCLIST $TRGLIST $TSTLIST | sed 's/ /%_%/g'`; do
#	echo $LINE;

	SRC=`echo $LINE | sed 's/%_%/ /g' | cut -f1 -d'!' | sed 's/^ *//g' | sed 's/ *$//g'`;
	TRG=`echo $LINE | sed 's/%_%/ /g' | cut -f2 -d'!' | sed 's/^ *//g' | sed 's/ *$//g'`;
	TST=`echo $LINE | sed 's/%_%/ /g' | cut -f3 -d'!' | sed 's/^ *//g' | sed 's/ *$//g'`;

	
	if [[ $TRG != $TST ]]; then
		echo -e $mode"\t  "$SRC"\n\t- $TRG\n\t+ "$TST"\n";
	else
		echo -e $mode"\t  "$SRC"\nWORKS\t  $TST\n";
		CORRECT=`expr $CORRECT + 1`;
	fi
	TOTAL=`expr $TOTAL + 1`;
done

echo $CORRECT" / "$TOTAL ;
if [ -x /usr/bin/calc ]; then
	WORKING=`calc $CORRECT" / "$TOTAL" * 100" | head -c 7`;

	echo $WORKING"%";
fi

rm $SRCLIST $TRGLIST $TSTLIST;