#!/bin/sh DB=/usr/local/WWW/data/akaho/data/database DB2=/usr/local/WWW/data/akaho/data/database2 TMPDB=/tmp/talk.find TMP=/tmp/talk.tmp NN=/usr/local/WWW/data/akaho/nn FREQ=/usr/local/WWW/data/akaho/freq RANDLINE=/usr/local/WWW/data/akaho/randline echo 'Content-type: text/html' echo "" echo ' Talk with me ' echo 'I am Valkyrie, let'"'"'s talk with me
' submit=`echo $QUERY_STRING | sed \ -e 's/+/ /g' -e 's/[Ii]nput=//' \ -e 's/%3F/?/g' -e 's/%27/'"'"/g \ -e 's/%20/ /g' \ -e 's/%2C/,/g' -e 's/%21/!/g'` if [ A"$submit" != A ]; then # if TMP/DB/DB2 do not exist, create it if [ ! -r $TMP ]; then echo "Talk with me" > $TMP fi if [ ! -w $DB ]; then touch $DB fi if [ ! -w $DB ]; then touch $DB2 fi # TMP is my previous saying prev=`cat $TMP` ocode=`echo $prev | $FREQ` # register my saying and user answer to DB echo "$ocode" "$submit" >> $DB code=`echo "$submit" | $FREQ` # find nearest neighbor answer lineno=`$NN $code 5 < $DB` echo "$code" "$submit" >> $DB2 if [ $lineno -eq 0 ]; then mywc=`wc -l $DB2 | awk '{print $1}'` mytmp="`$RANDLINE $mywc $DB2`" mymsg="`echo $mytmp | sed 's/^[0-9]* //'`" ocode=`echo "$mymsg" | $FREQ` sed "/$ocode/d" $DB2 > $DB2.tmp mv $DB2.tmp $DB2 else fcode=`sed -n ${lineno}p $DB | awk '{print $1}'` egrep $fcode $DB > $TMPDB mywc=`wc -l $TMPDB | awk '{print $1}'` mymsg="`$RANDLINE $mywc $TMPDB | sed 's/^[0-9]* //'`" fi # echo "$mymsg" > $TMP echo '

' "$mymsg" '


' else mymsg=`ls -l $DB | awk '{print $5, $6, $7}'` echo '

I cannot respond to nothing.

' echo last talk: "$mymsg" '
' fi echo ' Input any message (I will respond): ' echo '
' echo '' echo '' echo '

' echo '-> ' Akaho\''s Home Page

' echo '

akaho@etl.go.jp
' exit 0