-
Notifications
You must be signed in to change notification settings - Fork 242
/
Copy pathcheck_gibberish
executable file
·52 lines (42 loc) · 1.51 KB
/
check_gibberish
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
#! /bin/bash
# Check the spelling of the specified file as an indicator of
# whether the model produced gibberish - this doesn't catch low quality
# output, just utter garbage as a basic backstop
cat "$1"
########################################################################
#
# extract sequence from other output
TMPFILE=/tmp/`basename "$1"`-sequence
if [ "X$2" == "X--no-extract" ]; then
cp "$1" $TMPFILE
else
# We extract only the sequence output and don't spell check status and performance stats
python3 .ci/scripts/extract-sequence.py "$1" >$TMPFILE
if [ $? -ne 0 ]; then
echo "Sequence extraction failed. Exiting."
exit 1
fi
fi
#######################################################################
#
# check whether aspell spell check evailable
if command -v aspell &> /dev/null; then
echo "Checking $TMPFILE for gibberish"
else
echo "Aspell is not installed or not in PATH."
echo "Gibberish unchecked in $TMPFILE"
exit 0
fi
#######################################################################
#
# run spell check on the extracted sequence
cat ${TMPFILE} | aspell -a -c | grep '^[\&#]' >/tmp/out.$$
# Exit with a non-zero status code if there were any spelling errors because:
# * Finding one or more lines with & or # means we found a spelling error, might be gibberish
if [ $? -ne 0 ]; then
echo "No spelling errors found; likely correct operation. Success."
exit 0
fi
cat /tmp/out.$$
echo "Spelling errors found; might indicate garbage output. Failing."
exit 1