diff options
-rwxr-xr-x | spelling-rbee | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/spelling-rbee b/spelling-rbee index feedc82..da2905a 100755 --- a/spelling-rbee +++ b/spelling-rbee @@ -5,6 +5,13 @@ require "open-uri" words = [] correct = [] +def ckopt(word, result) + case result + when "_r" then system "espeak -s 100 #{word}" + when "_imacheaterandknowit" then puts word + end +end + open FILE do |f| f.each do |line| words.push line.chomp @@ -37,25 +44,19 @@ puts "words: %d" % words.length words.each {|word| system "espeak -s 100 '#{word}'" print "spell: " - $result = $stdin.gets.chomp! - if $result.start_with? "_" - case $result - when "_r" then system "espeak -s 100 #{word}" - when "_imacheaterandknowit" then puts word - end - while $result.start_with? "_" + result = $stdin.gets.chomp! + if result.start_with? "_" + ckopt(word,result) + while result.start_with? "_" print "spell: " - $result = $stdin.gets.chomp! - case $result - when "_r" then system "espeak -s 100 #{word}" - when "_imacheaterandknowit" then puts word - end + result = $stdin.gets.chomp! + ckopt(word,result) end end - if $result == word - correct.push [word, "correct", $result] + if result == word + correct.push [word, "correct", result] else - correct.push [word, "wrong", $result] + correct.push [word, "wrong", result] end } puts |