Skip to content

Instantly share code, notes, and snippets.

@cantlin
Created August 7, 2011 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cantlin/1130804 to your computer and use it in GitHub Desktop.
Save cantlin/1130804 to your computer and use it in GitHub Desktop.
#! /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