• 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
  • 相关阅读:
    国外名校课程视频爆红 网友总结“必杀技”(图)
    设置mysql密码
    Writing Linux LCD drivers—深入分析framebuffer设备驱动的结构
    LAMP架构中,php 与 php、php与C语言程序等 之间 的网络通信 问题
    API & ABI
    Linux 6初体验:桌面性能堪比新版Ubuntu
    diff 比较两个文件夹
    11种错误的保养皮肤习惯
    服务器领域Linux击败Windows的5大理由
    CentOS5.5 FTP安装配置
  • 原文地址:https://www.cnblogs.com/xuyanran/p/8166459.html
Copyright © 2020-2023  润新知