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
|
#!/bin/sh
TOOLDIR=../../tools/src
FORMAT_TOOL=
TXT_TOOL=
if [ "$1" = '--python' ]; then
FORMAT_TOOL="python3 ./hfst-format.py"
TXT_TOOL="python3 ./hfst-txt2fst.py"
else
FORMAT_TOOL=$TOOLDIR/hfst-format
TXT_TOOL=$TOOLDIR/hfst-txt2fst
for tool in $FORMAT_TOOL $TXT_TOOL; do
if ! test -x $tool; then
exit 77;
fi
done
fi
echo '0 1 a b
1' > TMP;
if $FORMAT_TOOL --test-format sfst; then
if cat TMP | $TXT_TOOL -f sfst > test ; then
if ! $FORMAT_TOOL test > TMP1 ; then
exit 1
fi
echo "Transducers in test are of type SFST (1.4 compatible)" > TMP2
if ! diff TMP1 TMP2 2> /dev/null > /dev/null; then
if [ "$1" = '--python' ]; then
if ! (grep 'SFST_TYPE' TMP1 2> /dev/null > /dev/null); then
exit 1
fi
else
exit 1
fi
fi
fi
fi
if $FORMAT_TOOL --test-format openfst-tropical; then
if cat TMP | $TXT_TOOL -f openfst-tropical \
> test ; then
if ! $FORMAT_TOOL test > TMP1 ; then
exit 1
fi
echo "Transducers in test are of type OpenFST, std arc,"\
"tropical semiring" > TMP2
if ! diff TMP1 TMP2 2> /dev/null > /dev/null; then
if [ "$1" = '--python' ]; then
if ! (grep 'TROPICAL_OPENFST_TYPE' TMP1 2> /dev/null > /dev/null); then
exit 1
fi
else
exit 1
fi
fi
fi
fi
if $FORMAT_TOOL --test-format foma; then
if cat TMP | $TXT_TOOL -f foma > test ; then
if ! $FORMAT_TOOL test > TMP1 ; then
exit 1
fi
echo "Transducers in test are of type foma" > TMP2
if ! diff TMP1 TMP2 2> /dev/null > /dev/null; then
if [ "$1" = '--python' ]; then
if ! (grep 'FOMA_TYPE' TMP1 2> /dev/null > /dev/null); then
exit 1
fi
else
exit 1
fi
fi
fi
fi
rm -f test
rm -f TMP
rm -f TMP1
rm -f TMP2
|