# unlearn_i lexicon unlearning_rate reinforcement_rate
# Eg - unlearn_i american 1 1
# For each word, remove the letter at a particular position (1 to 6).
# unlearn responsible connections in the errors and 
# reinforce selected connections in the original words.
foreach i ( 1 2 3 4 5 6)
# Test
	wrd_in -s -p $i < $1 | mlhn $1 -t | wrd_out > $1.tst
# First unlearn errors
# spurious $1
	diff -b $1 $1.tst | grep ">" | sed "s/> //" | sort -u > $1.tmp
	comm -23 $1.tmp $1 > $1.err
	rm $1.tmp
	set wc = `wc $1.err`
# unlearn spurious minima
	wrd_in -u $i $2 < $1.err | mlhn $1 -ns -c
	rm $1.err
# Now reinforce original words
# clean $1
diff -b $1 $1.tst | grep "<" | sed "s/< //" > $1.rt
# retrain (selected connections)
	wrd_in -r $i $3 < $1.rt | mlhn $1 -ns -c
	rm $1.rt
# Log error count
	echo -n $wc[1] >> $1.ulog
	echo -n " " >> $1.ulog
end
echo " " >> $1.ulog
