Debugging: Spring and a Dog Run

Yesterday was the official first day of Spring.  The last one was the time change.  Took the pups out for a 6.2 mile bike run on Sligo trail.  The creek needs some cleaning up, and the trail is not as smooth a ride as Rock Creek or Capital Crescent, but it is still quite nice.  There is also a tennis court with a wall at the Piney Branch parking lot.  2 courts – one with a wall.

Because the power was interrupted to most of the house, there was a significant expression of anger on my part which basically means since I can’t see what I’m doing in the kitchen in the evening, dishes don’t get washed, counters don’t get wiped, stuff is left out.  The kitchen is a mess.  Setting the anger aside, I’m going to have to invest a significant amount of time cleaning for Passover.  The car and clothes, too.  The oven also has to be cleaned.

Trying to eat everything that has yeast in it in the last 3 days.  Tamales, cereal, rice, crackers, bread and granola bars all have to go.  Life will become potatoes, fruit, carrots, and milk for a few days (a little over a week). Matzo ball soup to stay warm.

Some Computer Notes:

Getting the code up and running again required a couple of hours of work.  Copying the files from the computer messes up the quotation marks in a few different ways.  Double and single quotes become oriented, and have to be retranslated into their unoriented versions ” and ‘ with a global find and replace.  Sometimes the double quote becomes condensed into a much smaller version in a different font.  This also has to be fixed.

Quite nefariously, the hyphen is replaced with a lower hyphen.  This is hard to detect, but it shows up as the subtraction and other file searches not working.  A global replace fixes this as well.  It also has to be replaced on downloaded text files that include a hyphen in the quizzed word.

The single quotes on the sed command in the pipe on the music file search has to be fixed, or the music will play the same song from the same position over and over.

Also, the single quotes on the cut command need to be replaced with double quotes.

The grammar file works – I had to fix the directory names.

On this version of the code, I added a subdirectory to the news directory called “current_file”.  This is where I put the file that I want to work on, always calling it 01 spanish-news.txt.  This way I don’t have to work with all files at once.  I could probably put in an option in the program so that one could switch back and forth.  This was not yet done.

Donations (some catching up):

local dog shelter

creek clean up

bike trails

women in computer science

The code:

#!/bin/bash
# news_spanish.sh v.1.12 a program submitted by livedoggb on Mar 21/2013
# dependencies compiled random1.c, and intdiv2float.c and a news directory
# with files called 01 spanish-news.txt, 02 spanish-news.txt …
# itunes directory named news with songs that you want to use sequentially numbered 01 …, 02 …, 03 … etc.
# NYI: not yet implemented
# NYI: itunes directory named spanish-queensenglish highlit or french-queensennglish music with audio tracks of the queensenglish quotes made by you named french-queensenglish-01nouns01.avi, or spanish-queensenglish-01nouns01.avi, spanish-queensenglish-01nouns33.avi, etc.
# with the number corresponding to the line number of the noun in the text file.
# the number of files in each of the language directories must be the same right now.  The Spanish one is reference.
# It also outputs a file sommaire.out that has the statistics of your session.

mnt_path=”/mnt/sdb1/”
dir_path=”$mnt_path/news/”
temp_path=”/root/”
temp_file=”$temp_path/temp.out”
dir_cprog=$( echo “$mnt_path/for_kids/c_progs/” )
LANG=es_ES.UTF-8
music_flag=”on”
function echo_in_color_br_sentence {
case $choice in
1)
part1=$( echo $testline | sed “s/\(.*\)\(_*_\)\(.*\)/\1/” )
part2=$( echo $testline | sed “s/\(.*\)\(_*_\)\(.*\)/$echo_verb/” )
part3=$( echo $testline | sed “s/\(.*\)\(_*_\)\(.*\)/\3/” )
#”blue”
l1=$( echo “$part1”  | sed “s/_*//g”  | sed “s/ *//” )
#”red”
#echo -n -e ‘\E[47;31m'”33[1m””$part2″”33[0m” | sed “s/_*//g” | sed “s/ *//g” )
#”blue”
l2=$( echo “$part2” | sed “s/_*//g” | sed “s/ *//” )
#”blue”
l3=$( echo “$part3” | sed “s/_*//g” | sed “s/ *//” )
tput sgr0
line=$( echo -e ” $l1 “” $l2 “” $l3 ”  )
;;
2)
part1=$( echo $testline | sed “s/\(.*\)\(_*_\)\(.*\)/\1/” )
part2=$( echo $testline | sed “s/\(.*\)\(_*_\)\(.*\)/$echo_verb/” )
part3=$( echo $testline | sed “s/\(.*\)\(_*_\)\(.*\)/\3/” )
#”blue”
l1=$( echo “$part1”  | sed “s/_*//g”  | sed “s/ *//” )
#”red”
#echo -n -e ‘\E[47;31m'”33[1m””$part2″”33[0m” | sed “s/_*//g” | sed “s/ *//g” )
#”blue”
l3=$( echo “$part3” | sed “s/_*//g” | sed “s/ *//” )
tput sgr0
line=$( echo -e ” $l1 “” $l2 “” $l3 ”  )
l2=$( echo “$part2” | sed “s/_*//g” | sed “s/ *//” )
;;
3)
line=$( echo $testline | sed “s/\(.*\).$/\1/” )
;;
4)
;;
esac
return
}

function trim_line {
i=1
echo
LANG=es_ES.UTF-8
#num_words=$(gawk ‘{ sum += $1 }; END { print sum }’ testline.out)
words_left=”c”
while [ “$words_left” != “” ]
do
j=$(( $i + 8 ))
words_left=$( echo $line | cut -d” ” -f$i-$j )
echo $words_left
i=$(( $j + 1 ))
done
return
}

function read_sentence_outloud {
LANG=es_ES.UTF-8
if [ “$read_aloud” == “y” ]
then
repeat=”y”
sp=$( echo $sound_path2/”$random_verb_num”_”$language2″_full_quotes/”$quizfact”_*.* )
echo “directory path is: ” $sp
if [ -e “$sp” ]
then
while [ “$repeat” == “y” ]
do

#< /dev/null &
shighlit=$(grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.*  SENT:\(.*\)/\1/”)
line=$shighlit
#                    trim_line
echo
echo “Press enter when you are ready to hear the sentence read aloud.”
read ready
mplayer -volume 80 “$sp”
if [ $act == “read” ]
then
trim_line
verb_guess=””
asked=$(( $asked + 1 ))

echo “Read the sentences that you heard.  Repeat? (y or n. The default is n.)”
else
verb_guess=””
asked=$(( $asked + 1 ))

echo “Write the sentences that you heard.  Repeat? (y or n. The default is n.)”
fi
read repeat
if [ -e “$repeat” ]
then
repeat=”n”
fi
done
fi
fi
return
}

function show_the_sentence {
LANG=es_ES.UTF-8
l1=$( echo $language1 | sed -e “s/kids-//” )
echo -n “The $l1 current phrase is: ”

echo_in_color_noun_w_gender  “random quiz line is:” $quizfact
line=$testline
verb_guess=””
asked=$(( $asked + 1 ))
LANG=es_ES.UTF-8
echo_verb=$( grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^[0-9]*c: \(.*\)  ENG: \(.*\)  SENT: .*/\2/” )

if [ “$act” == “read” ]
then
if [ “$choice” == “1” ]
then
echo_in_color_br_sentence
fi
fi
trim_line
while [ -e $verb_guess ]
do
#l2=$( echo $language2 | sed -e “s/kids-queens//” )
echo “Enter a guess (enter e to exit):”
read verb_guess
done
if [ “$verb_guess” == “e” ]
then
break
fi

if [ “$verb_guess” == “$echo_verb” ]
then
echo “Correct.”
right=$(( $right + 1 ))
average=$(( $right/$asked ))
rightverbs=$( echo $rightverbs, $echo_verb)
if [ “$music_flag” == “on” ]
then
num_mus=$( $dir_cprog/random1 1 $num_files )
num_mus_fixed=$(echo $num_mus | sed -e “s/^0//”)
prob_time=$(( ${time_array[$num_mus_fixed]} – 20 ))
ssx=($(expr $($dir_cprog/random1 0 $prob_time)))
mplayer -msglevel all=-1 -profile gnome-mplayer -ss $ssx -endpos 20 -volume 200 /mnt/sda1/Documents\ and\ Settings/TEMP/My\ Documents/My\ Music/iTunes/iTunes\ Media/Music/news/$num_mus*.*
fi
else

echo “No.  The correct response is: ”  $echo_verb
echo   “random quiz line is:” $quizfact

wrongverbs=$( echo $wrongverbs, $echo_verb )
fi

echo
return
}

function read_clueword_outloud {
LANG=es_ES.UTF-8
if [ “$read_aloud” == “y” ]
then
repeat=”y”
sp=$( echo $sound_path1/”$random_verb_num”_”$language1″_sound/”$quizfact”_nouns_”*.*” )
echo “directory path is: ” $sp
ls $sp
if [ -e $sp ]
then
while [ “$repeat” == “y” ]
do

#< /dev/null &
#                    shighlit=$(grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.* SENTCOMP:\(.*\).*/\1/”)
#                    line=$shighlit
#                    trim_line
#                    echo
#                    echo “Press enter when you are ready to hear the foreign word read aloud.”
#                    read ready
mplayer -volume 80 $sp
#                    trim_line
l1=$( echo $language1 | sed -e “s/kids-//” )
echo “Write on a separate piece of paper, and repeat aloud the $l1 word that you heard.  Repeat? (y or n. The default is n.)”
read repeat
if [ -e “$repeat” ]
then
repeat=”n”
fi
done
echo -n “The word is: ”
echo_in_color_noun_w_gender
echo
echo -n “Did you write it down correctly? (y or n)”
read $mistake
if [ -e “$mistake” ]
then
mistake=0
fi
case “$mistake” in
default)
mistake=0
;;
“y”)
mistake=0
;;
“yes”)
mistake=0
;;
“n”)
mistake=1
;;
“no”)
mistake=1
;;
esac
sum_mistakes=$(( $sum_mistakes + $(( $mistake )) ))
fi
fi
LANG=es_ES.UTF-8
return
}

function read_englishword_outloud {
LANG=es_ES.UTF-8
if [ “$read_aloud” == “y” ]
then
repeat=”y”
sp=$( echo “$sound_path2″/”$random_verb_num”_”$language2″_sound/”$quizfact”_”*.*” )
echo “directory path is: ” $sp
if [ -e $sp ]
then
while [ “$repeat” == “y” ]
do

#< /dev/null &
#                    shighlit=$(grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.* SENTCOMP:\(.*\).*/\1/”)
#                    line=$shighlit
#                    trim_line
#                    echo
l1=$( echo $language1 | sed -e “s/kids-//” )
l2=$( echo $language2 | sed -e “s/kids-queens//” )
#                    echo “Press enter when you are ready to hear the $l2 word read aloud.”
#                    read ready
mplayer -volume 80 $sp
#                    trim_line

echo -n “The word in the $l1 language you are studying is: ”
echo_in_color_noun_w_gender
echo

echo “Write on a separate piece of paper and repeat aloud the $l2 word that you heard.  Repeat? (y or n. The default is n.)”
read repeat
if [ -e “$repeat” ]
then
repeat=”n”
fi
done
l1=$( echo $language1 | sed -e “s/kids-//” )
#              echo -n “The word in the $l1 language you are studying is: ”
#              echo_in_color_noun_w_gender
echo
echo -n “The word in $l2 you are studying is: ”
engnoun=$( grep “^$correctquizfact:” “$dir_txt_path2″/$fn*.txt | sed -e “s/^.*c:\(.*\)  ENG:.*/\1/” )
echo $engnoun
echo
echo -n “Did you write it down correctly? (y or n)”
read $mistake
if [ -e “$mistake” ]
then
mistake=0
fi
case “mistake” in
default)
mistake=0
;;
“y”)
mistake=0
;;
“yes”)
mistake=0
;;
“n”)
mistake=1
;;
“no”)
mistake=1
;;
esac
sum_mistakes=$(( $sum_mistakes + $(( $mistake )) ))
fi
fi
LANG=es_ES.UTF-8
return
}

function echo_in_color_noun_w_gender {
LANG=es_ES.UTF-8
l=$( echo $language | sed -e “s/kids-//” )
l=”spanish”
case $l  in
default)
LANG=es_ES.UTF-8
;;
“bulgarian”)
LANG=bg_BG.UTF-8
;;
“russian”)
LANG=ru_RU.UTF-8
;;
“german”)
LANG=de_DE.UTF-8
;;
“greek”)
LANG=el_GR.UTF-8
;;
“indonesian”)
LANG=id_ID.UTF-8
;;
“malay”)
LANG=id_ID.UTF-8
;;
“dutch”)
LANG=nl_NL.UTF-8
;;
“hungarian”)
LANG=hu_HU.UTF-8
;;
“polish”)
LANG=pl_PL.UTF-8
;;
“latvian”)
LANG=lv_LV.UTF-8
;;
“lithuanian”)
LANG=lt_LT.UTF-8
;;
“chinese”)
LANG=zh_CN.UTF-8
;;
“japanese”)
LANG=ja_JP.UTF-8
;;
“korean”)
LANG=ko_KR.UTF-8
;;
“arabic”)
LANG=ar_SY.UTF-8
n2=$( echo $noun )
echo   $( /mnt/sdb1/for_kids/c_progs/rev_str2 $n2 )
;;
“hebrew”)
LANG=he_IL.UTF-8
n2=$( echo $noun | sed -e “s/(.)//” )
#      echo $n2
#      $dir_cprog/rev_str2  $n2  > $temp_path/revheb
#      cat revheb
#      read
# echo $( echo $n2 )

#      a=$( echo $(echo “צלחן”) )
#     echo $a
#      n2=$( echo $noun | sed -e “s/  (.) //” )
#     echo $n2
#     n3=$( $dir_cprog/rev_str2 “$n2” )
#     echo $( echo “$n3″ )
# n2=”שדךגלחכי”
echo   $( /mnt/sdb1/for_kids/c_progs/rev_str2 $n2 )
#    rnoun=$( echo $n3 )
#     noun=$rnoun
;;
“norwegian”)
LANG=nn_NO
;;
“icelandic”)
LANG=nn_NO
;;
esac
LANG=es_ES.UTF-8
color=x
case “$color” in
“m”)
echo -e ‘\E[47;34m'”33[1m$noun33[0m”
;;
“f”)
echo -e ‘\E[47;31m'”33[1m$noun33[0m”
;;
“n”)#0CF82B
echo -e ‘\E[47;42m'”33[1m$noun33[0m”
;;
“x”)
echo “$noun”
;;
esac
LANG=es_ES.UTF-8
tput sgr0
return
}
function select_language2 {
lang_picked=”notpicked”
LANG=es_ES.UTF-8
while [ $lang_picked == “notpicked” ]
do
echo “Available reader languages are:”
echo  1. English
echo
echo -n “Enter a number:”
read lang_num
if [ “$lang_num” -gt 6 ]
then
echo “Language not yet available.  Pick another one. ”
fi
LANG=es_ES.UTF-8
case “$lang_num” in
1)
language=”kids-queensenglish”
lang_picked=”picked”
LANG=es_ES.UTF-8
;;
default)
language=”kids-queensenglish”
lang_picked=”picked”
LANG=es_ES.UTF-8
;;
esac
done
language2=$language
l2=$( echo $language2 | sed -e “s/kids-queens//” )
echo “This is a map of where ” $l2 “is spoken in the world.”
viewnior “$dir_path”/maps/”$l2″.png < /dev/null &
LANG=es_ES.UTF-8
return
}

function select_language1 {
LANG=es_ES.UTF-8
lang_picked=”notpicked”
while [ $lang_picked == “notpicked” ]
do
echo “Available clue languages are:”
echo  “1. French        16. Dutch”
echo  “2. German        17. Hindi”
echo  “3. Spanish       18. Urdu”
echo  “4. Italian       19. Sanskrit”
echo  “5. Portuguese    20. Swahili”
echo  “6. Greek         21. Afrikaans”
echo  “7. Hebrew        22. Bulgarian”
echo  “8. Arabic        23. Indonesian”
echo  “9. Farsi         24. Hungarian”
echo  “10. Syriac       25. Icelandic”
echo  “11. Chinese      26. Latvian”
echo  “12. Russian      27. Lithuanian”
echo  “13. Polish       28. Malay”
echo  “14. Irish        29. Japanese”
echo  “15. Norwegian    30. Korean”

echo
echo -n “Enter a number:”
read lang_num
#    if [ “$lang_num” -gt 6 ]
#       then
#         echo “Language not yet available.  Pick another one. ”
#    fi
LANG=es_ES.UTF-8
case “$lang_num” in
1)
language=”kids-french”
lang_picked=”picked”
LANG=es_ES.UTF-8
;;
2)
language=”kids-german”
lang_picked=”picked”
LANG=es_ES.UTF-8
;;
3)
language=”kids-spanish”
lang_picked=”picked”
LANG=es_ES.UTF-8
;;
4)
language=”kids-italian”
lang_picked=”picked”
LANG=es_ES.UTF-8
;;
5)
language=”kids-portuguese”
lang_picked=”picked”
LANG=es_ES.UTF-8
;;
6)
language=”kids-greek”
lang_picked=”picked”
LANG=es_ES.UTF-8
;;
7)
language=”kids-hebrew”
lang_picked=”picked”
;;
8)
language=”kids-arabic”
lang_picked=”picked”
;;
9)
language=”kids-farsi”
lang_picked=”picked”
;;
10)
language=”kids-syriac”
lang_picked=”picked”
;;
11)
language=”kids-chinese”
lang_picked=”picked”
;;
12)
language=”kids-russian”
lang_picked=”picked”
;;
13)
language=”kids-polish”
lang_picked=”picked”
;;
14)
language=”kids-irish”
lang_picked=”picked”
;;
15)
language=”kids-norwegian”
lang_picked=”picked”
;;
16)
language=”kids-dutch”
lang_picked=”picked”
;;
17)
language=”kids-hindi”
lang_picked=”picked”
;;
18)
language=”kids-urdu”
lang_picked=”picked”
;;
19)
language=”kids-sanskrit”
lang_picked=”picked”
;;
20)
language=”kids-swahili”
lang_picked=”picked”
;;
21)
language=”kids-afrikaans”
lang_picked=”picked”
;;
22)
language=”kids-bulgarian”
lang_picked=”picked”
;;
23)
language=”kids-indonesian”
lang_picked=”picked”
;;
24)
language=”kids-hungarian”
lang_picked=”picked”
;;
25)
language=”kids-icelandic”
lang_picked=”picked”
;;
26)
language=”kids-latvian”
lang_picked=”picked”
;;
27)
language=”kids-lithuanian”
lang_picked=”picked”
;;
28)
language=”kids-malay”
lang_picked=”picked”
;;
29)
language=”kids-japanese”
lang_picked=”picked”
;;
30)
language=”kids-korean”
lang_picked=”picked”
;;
default)
language=”kids-spanish”
lang_picked=”picked”
;;
esac
language1=$language
l1=$( echo $language1 | sed -e “s/kids-//” )
echo “This is a map of where ” $l1 “is spoken in the world.”
viewnior “$dir_path”/maps/”$l1”.png < /dev/null &
done
LANG=es_ES.UTF-8
return
}

function set_paths {
LANG=es_ES.UTF-8
#clue language is lang1
#reading language is lang2
lang2=$( echo “$language2”)
tvf2=$( echo “$lang2”)
dir_txt_path2=$( echo “$dir_path”/$tvf2/$lang2/current_file )
tvs2=$( echo “$tvf2″_sound )
lang1=$( echo “$language1″”$lang2”)
tvf1=$( echo “$lang1”)
dir_txt_path1=$( echo “$dir_path”/$lang2/$tvf1/current_file )
tvs1=$( echo “$tvf1″_sound )
sound_path1=$( echo “$dir_path”/$tvs2/”$language1″_sound_nouns/ )
sound_path2=$( echo “$dir_path”/$tvs2/”$language2″_sound_nouns/ )

case “$choice” in
default)
lang2=$( echo “$language2”)
tvf2=$( echo “$lang2”)
dir_txt_path2=$( echo “$dir_path”/$tvf2/$lang2 )
tvs2=$( echo “$tvf2″_sound )

lang1=$( echo “$language1″”$lang2”)
tvf1=$( echo “$lang1”)
dir_txt_path1=$( echo “$dir_path”/$lang2/$tvf1/ )
tvs1=$( echo “$tvf1″_sound )
sound_path1=$( echo “$dir_path”/$tvs2/”$language1″_sound_nouns/ )
sound_path2=$( echo “$dir_path”/$tvs2/”$language2″_sound_nouns/ )
;;
3)
tvf2=$( echo “$lang2”)
dir_txt_path2=$( echo “$dir_path”/$tvf2/$lang2/span_grammar/ )
tvf1=$( echo “$lang1”)
dir_txt_path1=$( echo “$dir_path”/$lang2/$tvf1/span_grammar/ )
;;
4)
tvf2=$( echo “$lang2”)
dir_txt_path2=$( echo “$dir_path”/$tvf2/$lang2/span_grammar/ )
tvf1=$( echo “$lang1”)
dir_txt_path1=$( echo “$dir_path”/$lang2/$tvf1/span_grammar/ )
;;
esac

#echo “Clue working language path is: ” $dir_txt_path1
#ls $dir_txt_path1
#echo “Reading working language path is: ” $dir_txt_path2
#ls $dir_txt_path2
#echo “Clue working sound path is: ” $sound_path1
#ls $sound_path1
#echo “Reading working sound path is: ” $sound_path2
#ls $sound_path2
LANG=es_ES.UTF-8
return
}

clear
#select_language2
#select_language1
set_paths
LANG=es_ES.UTF-8
if [ -e $temp_path/sommaire.out ]
then
rm $temp_path/sommaire.out
fi
#rm $dir_path/hyper-tense-files_used.out
sum_fautes=0
if [ -e $dir_path/current_file ]
then
echo “directory path passed.”
else
echo “directory path not valid.  Your USB device might be mounted under a different name.  Reset path on line 11 and start over.”
read
fi
echo “Please wait for a few minutes while the system sets up the music database.”
if [ -e $temp_path/$language-time2.out ]
then
echo “The program has found a time file.”
echo “1. Use this file.”
echo “2. Make a new time file. Choose 2 if you have changed the music.”
echo “Please choose:  (If you aren´t sure, choose 2.  The default is 2.)”
read choice
else
echo “0” > $temp_path/$language-time2.out
choice=2
fi
if [ -e $choice ]
then
choice=2
fi

case $choice in
1)
echo “Using the old file.”
;;
2)
echo “Making another file.  This will take a few minutes.  Please be patient.”
if [ -e $temp_path/$language-time2.out ]
then
rm $temp_path/$language-time2.out
fi
echo “0” > $temp_path/$language-time2.out
mplayer -msglevel all=-1 -profile gnome-mplayer -ss 10 -endpos 1 -volume 0 /mnt/sda1/Documents\ and\ Settings/TEMP/My\ Documents/My\ Music/iTunes/iTunes\ Media/Music/news/*.* | tee “$temp_file” | grep “^A: ” | sed -e “s/^A: .* of \([0-9]*\).* .*/\1/g” >> $temp_path/$language-time2.out
;;
esac

time_array=($(cat $temp_path/$language-time2.out))
i=1
num_files=0
num_files=$(expr $(grep -c . $temp_path/$language-time2.out))

i=0
while [ $i -lt $num_files ]
do
echo “$i. ${time_array[$i]}”
i=$(( $i + 1 ))
done
num_files=$(( $num_files – 1 ))
echo “num_files=” $num_files
echo
echo “Use music? (y or n): default is y.”
read ans
if [ “$ans” == “n” ]
then
music_flag=”off”
fi
echo
echo “Several options are possible.  Please choose a level (enter a number between 1 and 6).”
echo
echo “Level 1.  Find the words.”
echo “Level 2.  Guess the words.”
echo “Level 3.  Spanish grammar. English to Spanish translation.”
#echo “Level 4.  Spanish grammar.  English to Spanish translation.”
#echo “Level 3.  Write the $l2 word that you hear.”
#echo “Level 4.  Read the sentence after listening to it.”
#echo “Level 5.  Write the sentence after listening to it.”
#echo “Level 6.  Quiz mode – Just the word and music.”
#echo “Level 7.  Quiz mode – comprehensive.”
echo
echo -n “Level?”
read choice
#echo  “With oral reading? Choose y or n.  Default is n.”
#read read_aloud
if [ -e $read_aloud ]
then
read_aloud=”n”
fi

case “$choice” in
1)
echo “Level 1.”
echo “Find the words.”
sum_mistakes=0
;;
2)
echo “Level 2.”
echo “Guess the words.”
sum_mistakes=0
;;
3)
echo “Level 3.”
echo “Translate the sentence into Spanish.”
set_paths
#echo “Write the $language2 word that you hear.”
#sum_mistakes=0
;;
4)
#echo “Level 4.”
#echo “Translate the sentence into English.”
#set_paths
#echo “Read the sentence after listening to it.”
;;
5)
echo “Level 5.”
echo “Write the sentence after listening to it.”
;;
6)
echo “Level 6.”
echo “Quiz mode – just the word and music.”
;;
7)
echo “Level 7.”
echo “Quiz mode – comprehensive.”
;;
esac

echo “All information derives from .txt files in the folder ” $dir_txt_path
language_primer=$( echo $dir_txt_path2 )
c=””
right=0
asked=0
rightverbs=””
wrongverbs=””
average=0
verb_guess=””
LANG=es_ES.UTF-8
num_vfiles=$(expr $(ls -1  $dir_txt_path2/*.txt | grep -c . ))
hours_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\1/”| sed “s/0\([0-9]\)/\1/” )
min_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\2/”| sed “s/0\([0-9]\)/\1/” )
sec_bgn=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\3/”| sed “s/0\([0-9]\)/\1/” )

while [ -e $c ]
do
random_verb_num=$( “$dir_cprog”/random1 1 $num_vfiles)
fn=$random_verb_num
echo “random_verb_num is:” $random_verb_num
verb=$(ls $dir_txt_path1/$fn*.txt | sed “s/^.*$fn \(.*\).txt/\1/” )
if [ -e “$dir_txt_path1″/$fn*.txt ]
then
maxlinenum=$( grep -c . $dir_txt_path1/$fn*.txt)
maxlinenum=$(( $maxlinenum – 1 ))
quizfact=$( “$dir_cprog”/random1 1 $maxlinenum)
correctquizfact=$( echo “$quizfact”c)
omit_line=$( grep “^$correctquizfact:” “$dir_txt_path1″/$fn*.txt)
#      echo “random quiz line is:” $quizfact $correctquizfact
if [ “$omit_line” != “” ]
then
noun=$( grep “^$correctquizfact:” “$dir_txt_path1″/$fn*.txt | sed -e “s/^.*:\(.*\)  ENG: \(.*\)  SENT:.*/\1/” )
# echo “The current phrase is” $noun
case $choice in
default)
echo “Not a valid choice.”
exit
;;
1)
testline=$( grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.*SENT:\(.*\)/\1/” )
act=”read”
show_the_sentence
#read_sentence_outloud
;;
2)
testline=$( grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.*SENT:\(.*\)/\1/” )
act=”read”
show_the_sentence
#read_sentence_outloud
;;
3)
#read_englishword_outloud
#testline=$( grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.*SENT:\(.*\)SENTCOMP:.*/\1/”)
testline=$( grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.*SENT:\(.*\)/\1/”)
act=”read”
show_the_sentence
read_sentence_outloud
;;
4)
testline=$( grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.*ENG:\(.*\)SENT:.*/\1/”)
act=”read”
#show_the_sentence
read_sentence_outloud
;;
5)
testline=$( grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.*SENTCOMP:\(.*\)/\1/” )
act=”write”
read_sentence_outloud
act=”read”
show_the_sentence
trim_line
echo “Count the number of mistakes in what you wrote. One point for every word.”
echo How many errors?
read fault_number
if [ -e $fault_number ]
then
fault_number=0
fi
sum_faults=$(( $sum_faults + $fault_number ))
;;
6)
testline=$( grep “^$correctquizfact:” “$language_primer”/$fn*.txt | sed -e “s/^.*SENTCOMP:\(.*\)/\1/”)
show_the_sentence
;;
7)
read_clueword_outloud
testline=$( grep “^$correctquizfact:” $language_primer/$fn*.txt | sed -e “s/^.*SENTCOMP:\(.*\)/\1/” )
show_the_sentence
act=”write”
read_sentence_outloud
act=”read”
show_the_sentence
trim_line
echo “Count the number of mistakes in what you wrote. One point for every word.”
echo How many errors?
read fault_number
if [ -e $fault_number ]
then
fault_number=0
fi
sum_faults=$(( $sum_faults + $fault_number ))
;;
esac

#show_the_sentence

fi
fi
#trans_sent=$(grep “^$correctquizfact:” $dir_txt_path/$fn*.txt | sed -e “s/^.*SENTCOMP:\(.*\)/\1/”)
#
#shighlit=$(grep “^$correctquizfact:” $language_primer/$fn*.txt | sed -e “s/^.* SENTCOMP:\(.*\).*/\1/”)
#line=$shighlit
#trim_line

#echo “Please finish by reading the above sentence out loud.”
#read
echo “The line number is:” $quizfact
#echo $testline | sed “s/.*(\(.*\)).*/\1/”
#echo $testline | sed “s/(.*)/$echo_verb/”
#echo $trans_sent
echo $echo_verb
aver_right=$( $dir_cprog/intdiv2float $right $asked | sed -e “s/\([0-9]*\…\).*/\1/” )
echo $right “/” $asked ” correct.  Batting average:” $aver_right “Dictation errors: ” $sum_faults “Mistakes: ” $sum_mistakes
echo “Please wait while I look for another question…”
done
hours_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\1/”| sed “s/0\([0-9]\)/\1/” )
min_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\2/”| sed “s/0\([0-9]\)/\1/” )
sec_end=$( date| sed “s/.* \(..\):\(..\):\(..\).*/\3/”| sed “s/0\([0-9]\)/\1/” )
hours_diff=$(( $hours_end – $hours_bgn ))
min_diff=$(( $min_end – $min_bgn ))
sec_diff=$(( $sec_end – $sec_bgn ))
midnight=12
if [ $hours_diff -lt 0 ]
then
hours_diff=$(( $(( $midnight – $hours_bgn )) + $hours_end ))
# fix hour change if it happens at midnight or noon,
fi
time_of_ans=$(( $hours_diff * 60 + $min_diff ))
aver_time=$( $dir_cprog/intdiv2float $time_of_ans $((asked – 1)) | sed -e “s/\([0-9]*\…\).*/\1/” )
wrong=$(( $asked – $right – 1 ))
echo “You worked ” $time_of_ans “minutes for an average of: ” $aver_time “minutes per question, and a sum of ” $(($asked – 1)) “questions with ” $wrong ” mistakes and ” $sum_faults “dictation faults.” | tee >> $temp_path/sommaire.out
echo “The correct nouns (” $right “):” $rightverbs  | tee >>$temp_path/sommaire.out
echo “The incorrect nouns (” $wrong “):” $wrongverbs | tee >>$temp_path/sommaire.out
num_entries=$(grep “^[0-9]*c:” $dir_path/current_file/*.txt | grep -c .)
echo “The database had ” $num_entries “entries.” | tee >>$temp_path/sommaire.out
echo “Your percentage: ” $aver_right | tee >>$temp_path/sommaire.out
cat $temp_path/sommaire.out

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s