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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#!/bin/sh
TOOLDIR=../../tools/src
TOOL=
FORMAT_TOOL=
if [ "$1" = '--python' ]; then
TOOL="python3 ./hfst-lookup.py"
FORMAT_TOOL="python3 ./hfst-format.py"
else
TOOL=$TOOLDIR/hfst-lookup
FORMAT_TOOL=$TOOLDIR/hfst-format
for tool in $TOOL $FORMAT_TOOL; do
if ! test -x $tool; then
exit 77;
fi
done
fi
if ! $TOOL -s cat.hfst < $srcdir/cat.strings > test.lookups ; then
exit 1
fi
$FORMAT_TOOL -l > TMP;
# test what strings the transducer [a:b (ID:ID)*] recognizes
for i in "" .sfst .ofst .foma; do
if ((test -z "$i") || $FORMAT_TOOL --list-formats | grep $i > /dev/null); then
if test -f abid$i ; then
if ! echo "aa" | $TOOL -s abid$i \
> test.lookups;
then
exit 1
fi
if ! grep -q "inf" test.lookups; then
echo "FAIL: string 'aa' should not be recognized"
exit 1
fi
if ! echo "ab" | $TOOL -s abid$i \
> test.lookups;
then
exit 1
fi
if ! grep -q "inf" test.lookups; then
echo "FAIL: string 'ab' should not be recognized"
exit 1
fi
if ! echo "ac" | $TOOL -s abid$i \
> test.lookups;
then
exit 1
fi
if grep -q "inf" test.lookups; then
echo "FAIL: string 'ac' should be recognized"
exit 1
fi
fi
if test -f infinitely_ambiguous$i ; then
if ! echo "ad" | $TOOL infinitely_ambiguous$i \
2> warnings > test.lookups;
then
exit 1
fi
if ! grep -q "infinite" warnings; then
echo "FAIL: infinitely ambiguous string 'ad' should give a warning"
exit 1;
fi
if ! echo "b" | $TOOL infinitely_ambiguous$i \
2> warnings > test.lookups;
then
exit 1
fi
if grep -q "infinite" warnings; then
echo "FAIL: unambiguous string 'b' should not give a warning"
exit 1;
fi
fi
if test -f infinitely_ambiguous_with_flags$i ; then
if ! echo "a" | $TOOL infinitely_ambiguous_with_flags$i \
2> warnings > test.lookups;
then
exit 1
fi
if ! grep -q "infinite" warnings; then
echo "FAIL: infinitely ambiguous string 'a' should give a warning"
exit 1;
fi
if ! echo "b" | $TOOL infinitely_ambiguous_with_flags$i \
2> warnings > test.lookups;
then
exit 1
fi
if grep -q "infinite" warnings; then
echo "FAIL: unambiguous string 'b' should not give a warning"
exit 1;
fi
fi
fi
done
rm TMP
rm test.lookups
rm warnings
|