zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    C++数组释放问题
    C# 线程与进程
    Inspector面板Debug模式
    Unity实现汉诺塔游戏
    Unity中的销毁方法
    如何修改Unity中脚本模板
    序列帧动画
    Unity中的射线和射线图层过滤使用方法
    简单第一人称射击游戏
    C# 集合和泛型
  • 原文地址:https://www.cnblogs.com/xuyanran/p/8166459.html
Copyright © 2011-2022 走看看