Spell checker using hash table

Problem description

Given a text file, show the spell errors from it.  (https://www.andrew.cmu.edu/course/15-200/s06/applications/labs/lab3/) 

Psuedo Code

The Dictionary Hash Table  (Error Detection)

      Read thru a file which contains all right words, with Key = each word, value = each word.

You have been provided with a dictionary that contains root words. These should be inserted into the dictionary hash table based on the hashCode() of their String representation.

The Misspellings Hash Table (Remediation)

You should create a new class of Objects to represent misspelled words. It should contain the misspelling and the correct spelling and should be able to report each. It should also override the hashCode() method to return the hashCode() of the misspelling. This will enable the retrieve() method of your hash table to find this object and the correct spelling within it, given the misspelling.

Finding Root Words using the following sequence

The provided dictionary only contains root words, not each of their forms. So, in order to find a word, you might need to reduce it to its root form. So, for each word, you should try at least the following:
  • The word exactly as it appears in the user-provided text
  • If the word ends in -ing, remove the -ing - 进行时, remove ing
  • If the word ends in -ing, remove the -ing and add -e - 进行时,remove ing再加e
  • If the word ends in -s, remove the -s  --加s的复数
  • If the word ends in -es, -ly, or -ed, remove the -es, -ly, or -ed - 加es的复数, 加ed的形容词, 加ly的副词, 后缀全都拿掉
  • If the word ends in -ies, remove the -ies, and add -y   - ies结尾的复数, 删掉加个y
  • If the word ends in -es or -ed, remove the --s or --d - es, ed结尾的复数和形容词, 只去掉s和d

foreach (var word in Text)
{
   if (word in good words hash table)      
   {
       continue; 
    }
   else
   {
         can convert to the root words?
               if yes, map hashtable, fail, report error
               if no after going thru all rules, report error
   }
}    
View Code
原文地址:https://www.cnblogs.com/xuyanran/p/8166459.html