B=0
TOT=0
TITLE="$(basename $PWD) - CAPTCHA test"
HEADER="<html><head><title>$TITLE</title><style>img { min-width: 100px;min-height:60px} img.ans { border:red solid thin}</style><body>"
RESULTS=''
for i in *.png
	do
	ANSWER=`sed -e 's/image_\([a-z]*\)_.*$/\1/' <<<$i`
	A=`tesseract "$i" stdout --dpi 70 --psm 13 -c tessedit_char_whitelist=abcdefghijklmnopqrstuvwxyz | tr '[:upper:]' '[:lower:]' | sed -e 's/[^a-z]//g'`
	RESULTS="$RESULTS <img src='$i' loading='lazy' title='Answer: $ANSWER; OCR: ${A// /}' "
	if [ "${A// /}" == "$ANSWER" ]
		then RESULTS="$RESULTS class='ans' "
		B=$(($B+1))
	fi
	RESULTS="$RESULTS >"
	TOT=$(($TOT+1))
done

RESULTS="$RESULTS </body></html>"
echo $HEADER
echo "<h1>$TITLE</h1>"
echo "<p>$1</p>"
echo "<p>Captcha proposed by Amir on <a href="https://phabricator.wikimedia.org/T141490#9460756">T141490#9460756</a> based on linekern. Using font FreeMonoBoldOblique.</p>"
echo "<p><small>View other captcha tests: <a href="../setB/index.htm">Current captcha</a> | <a href="../tim/index.htm">Tim's proposal</a> | <a href="../img/index.htm">Tim's captcha without gradiant</a> | <a href="../ocr/index.htm">Current captcha with OCR rejection</a> | <a href="../setG/index.htm"> Using negative kerning and less harriness [Bawolff's proposal]</a> | <a href="../setF/index.htm">Negative kerning and harriness</a> | <a href="../linekern/index.htm"> Using linekern</a>| <a href="../amir-freesans/index.htm">Using FreeSans font</a> |<a href="../amir-djsans/index.htm">Using DejaVu Sans</a></small></p>" 
echo "<p>Using custom solve script (not just tesseract). success on this set is $B (out of $TOT) or <b>"
bc <<< "scale=1;$B*100/$TOT"
echo "%</b></p><hr>"
echo $RESULTS
