summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Parri <simonparri@ganzeria.com>2019-02-01 14:29:13 -0600
committerSimon Parri <simonparri@ganzeria.com>2019-02-01 14:29:13 -0600
commitd2bd0e19cb049269d51953a17d561b0aeaab5dfb (patch)
tree4595415ad6afc8c40b9bfc6121fef234c3ce2398
downloadspelling-rbee-d2bd0e19cb049269d51953a17d561b0aeaab5dfb.tar.gz
spelling-rbee-d2bd0e19cb049269d51953a17d561b0aeaab5dfb.zip
Initial Commit
spelling-rbee is a spelling program written in ruby and reading from .txt files. It is licenced under the Gnu General Public licence Version 3, or any later version, at your option.
-rw-r--r--README30
-rwxr-xr-xspelling-rbead27
-rwxr-xr-xspelling-rbee57
3 files changed, 114 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..c409ead
--- /dev/null
+++ b/README
@@ -0,0 +1,30 @@
+SPELLING-RBEE
+The spelling bee in ruby.
+
+spelling-rbee is a spelling bee program that can be used with any
+.txt file that follows the format of one thing to spell per each line.
+(note that you can have more than one word per line, you just have to type the whole line.)
+
+Dependencies:
+espeak
+ruby
+ruby open-uri module
+
+Useage:
+./spelling-rb <url>
+
+
+SPELLING-RBEAD
+The spelling ruby reader.
+
+spelling-rbead is the email reader for spelling-rbee. You can use it to read your email
+for a message that begins with the line spelling and that then follows the format for spelling-rbee.
+This a way to make .txts for spelling-rbee (however it is not the only way.)
+
+Dependencies:
+ruby
+ruby net/imap
+an existing file to write to
+
+Useage:
+./spelling-rbead <server> <username> <password> <address who sent the list> <file to write to>
diff --git a/spelling-rbead b/spelling-rbead
new file mode 100755
index 0000000..c8671e1
--- /dev/null
+++ b/spelling-rbead
@@ -0,0 +1,27 @@
+#!/usr/bin/ruby
+
+require "net/imap"
+server = ARGV[0]
+user = ARGV[1]
+password = ARGV[2]
+from = ARGV[3]
+writefile = ARGV[4]
+
+#Net::IMAP.debug = true
+imap = Net::IMAP.new(server)
+imap.login(user, password)
+imap.select "inbox"
+n = imap.search(%W/FROM #{from}/).last
+if n
+ msgs = imap.fetch n, "body[1.text]"
+ c = msgs[0].attr["BODY[1.TEXT]"]
+ b,w = c.split("\n",2)
+ if b.chomp == "spelling"
+ words = w.split "\n"
+ end
+end
+imap.logout
+
+file = File.open(writefile, "w")
+file.puts words
+file.close
diff --git a/spelling-rbee b/spelling-rbee
new file mode 100755
index 0000000..62ed1bd
--- /dev/null
+++ b/spelling-rbee
@@ -0,0 +1,57 @@
+#!/usr/bin/ruby
+
+FILE = ARGV[0] || "http://zoar.cx/~simon/21k/words.txt"
+require "open-uri"
+words = []
+correct = []
+
+=begin
+open FILE do |f|
+ f.each do |line|
+ words.push line.chomp
+ end
+end
+=end
+
+file = open FILE
+neof = true
+while neof
+ line = file.gets
+ if line == nil
+ neof = false
+ break
+ end
+ if line
+ line.chomp!
+ words.push line
+ end
+end
+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? "_"
+ print "spell: "
+ $result = $stdin.gets.chomp!
+ case $result
+ when "_r" then system "espeak -s 100 #{word}"
+ when "_imacheaterandknowit" then puts word
+ end
+ end
+ end
+ if $result == word
+ correct.push [word, "correct", $result]
+ else
+ correct.push [word, "wrong", $result]
+ end
+}
+puts
+correct.each {|word|
+ puts word[0] + ": " + word[1] + ": " + word[2]
+}