Module: SpellCheck
- Defined in:
- lib/spell_check.rb,
lib/spell_check/version.rb
Constant Summary collapse
- VERSION =
'0.0.2'
Class Method Summary collapse
-
.checkWord(aWordToCheck) ⇒ String
Checks if input word exists in dictionary.
Class Method Details
.checkWord(aWordToCheck) ⇒ String
Checks if input word exists in dictionary. This method will accept any case and will make corrections for any over-repeated strings.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/spell_check.rb', line 11 def self.checkWord( aWordToCheck ) @dict = Dictionary.new not_found = 'no correction found' # Check for any non-alphabet characters. If any are found, cease word search return not_found if has_non_alphabet_chars aWordToCheck # Adjust word for case word = adjust_case( aWordToCheck ) # Attempt to see if input word is found before doing regular expression search corrected_word = @dict.find_word word return corrected_word unless corrected_word.nil? # Input word was not found, so try matching regular expression corrected_word = correct_repetitions word return corrected_word unless corrected_word.nil? return not_found end |