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
  • 相关阅读:
    《哈佛商业评论》2018正刊12期与增刊25期的点评
    《财经》2018年共30+1期的点评与摘抄
    4星|《人人都在说谎》:社会科学方面有趣的数据分析方法与结论
    3星|侯世达《我是个怪圈》:关于人类意识的各种哲学思辨
    虚拟机 SUSE Linux Enterprise Server 12 SP2 64
    虚拟机 CentOS7 64
    虚拟机 ubuntu 16.04
    虚拟机 windows xp sp3 原版
    C#实现控制Windows系统关机、重启和注销的方法
    日期时间设置 "2018-05-04T16:36:23.6341371+08:00" 格式
  • 原文地址:https://www.cnblogs.com/xuyanran/p/8166459.html
Copyright © 2011-2022 走看看