Created
August 7, 2011 21:15
-
-
Save cantlin/1130804 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
require 'dictionary' | |
require 'suggester' | |
dict = Dictionary.new | |
loop do | |
print '> ' | |
word = gets | |
match = false | |
if dict.include? word | |
match = word | |
else | |
variants = Suggester.variants_for word | |
match = (dict.include_any? variants) | |
end | |
if !match | |
suggestions = Suggester.suggestions_for word | |
suggestions.each do |suggestion| | |
match = suggestion and break if dict.include? suggestion | |
end | |
end | |
print match || "NO SUGGESTIONS\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment