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
}
}

Spell checker using hash table的更多相关文章

  1. 散列表(hash table)——算法导论(13)

    1. 引言 许多应用都需要动态集合结构,它至少需要支持Insert,search和delete字典操作.散列表(hash table)是实现字典操作的一种有效的数据结构. 2. 直接寻址表 在介绍散列 ...

  2. 哈希表(Hash Table)

    参考: Hash table - Wiki Hash table_百度百科 从头到尾彻底解析Hash表算法 谈谈 Hash Table 我们身边的哈希,最常见的就是perl和python里面的字典了, ...

  3. Berkeley DB的数据存储结构——哈希表(Hash Table)、B树(BTree)、队列(Queue)、记录号(Recno)

    Berkeley DB的数据存储结构 BDB支持四种数据存储结构及相应算法,官方称为访问方法(Access Method),分别是哈希表(Hash Table).B树(BTree).队列(Queue) ...

  4. 几种常见 容器 比较和分析 hashmap, map, vector, list ...hash table

    list支持快速的插入和删除,但是查找费时; vector支持快速的查找,但是插入费时. map查找的时间复杂度是对数的,这几乎是最快的,hash也是对数的.  如果我自己写,我也会用二叉检索树,它在 ...

  5. PHP内核探索之变量(3)- hash table

    在PHP中,除了zval, 另一个比较重要的数据结构非hash table莫属,例如我们最常见的数组,在底层便是hash table.除了数组,在线程安全(TSRM).GC.资源管理.Global变量 ...

  6. php Hash Table(四) Hash Table添加和更新元素

    HashTable添加和更新的函数: 有4个主要的函数用于插入和更新HashTable的数据: int zend_hash_add(HashTable *ht, char *arKey, uint n ...

  7. php Hash Table(一) Hash Table的结构

    关于Hash Table专题: 一直想深入理解一下php的hash table的实现,以前一直是星星点点的看看,从未彻底的总结过,那就从这个专题开始吧! 主要想总结几个部分:hashtable结构,h ...

  8. Spell checker

     Spell checker Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Subm ...

  9. Hash Table 的实现步骤是什么

    什么是HashTable Hash Table 是计算机科学中很重要的一种数据结构,其时间复杂度为O(1),主要是通过把关键字Key 映射到数组中的一个位置来访问记录,所以速度相当快.映射函数称为 H ...

随机推荐

  1. Dockerfile的HEALTHCHECK指令

    容器实例的状态虽然是up,但不能保证里面的进程一定是监控的.我门可以借助HEALTHCHECK指令来做监控状态检查 HEALTHCHECK指令有两种形式: HEALTHCHECK [OPTIONS] ...

  2. Python while 循环

     while循环的使用 count = 0 while True: print("conunt:",count) conunt = conunt +1 注:while:作为循环命令 ...

  3. Python Redis 常用操作

    delete(*names) # 根据删除redis中的任意数据类型 exists(name) # 检测redis的name是否存在 keys(pattern='*') # 根据模型获取redis的n ...

  4. 新建Maven项目建成后本应该有的src/main/java和src/test/java目录并没有出现:

    转自:http://www.cnblogs.com/dong-dong-dong/p/9565466.html 新建Maven项目建成后本应该有的src/main/java和src/test/java ...

  5. topcoder srm 565 div1

    problem1 link $f[i][j]$表示经过前$i$个怪物之后,花费$j$个硬币可以得到的最大值. problem2 link 设$nim[i]$表示数字$i$的nim值.那么题目就是求有多 ...

  6. Learning-MySQL【6】:视图、触发器、存储过程、函数、流程控制

    一.视图 视图就是通过查询得到一张虚拟表,然后保存下来,下次用的直接使用即可.使用视图我们可以把查询过程中的临时表摘出来,用视图去实现,这样以后再想操作该临时表的数据时就无需重写复杂的 SQL 语句了 ...

  7. Codeforces Round #495 (Div. 2) C. Sonya and Robots

    http://codeforces.com/contest/1004/problem/C 题意: 在一行上有n个数字,现在在最左边和最右边各放置一个机器人,左右机器人各有一个数字p和q.现在这两个机器 ...

  8. 剑指offer 03:从尾到头打印链表

    题目描述 输入一个链表,按链表值从尾到头的顺序返回一个ArrayList. 递归法 /** * public class ListNode { * int val; * ListNode next = ...

  9. 补充一下 sizeof

    sizeof是一个运算符,给出某个类型或变量在内存中所占据的字节数 sizeof(int) //告诉你int占据几个字节 sizeof(i) //告诉你i这个变量占据几个字节 注:sizeof是静态运 ...

  10. ES6的小知识(后半部分)

    一.iterator和for-of循环 在js里有数组和对象,es6又新出现了set和map这样js就有了四种数据集合,这样可以组合使用他们,比如数组里拥有对象,set等,这样就需要一个统一的 接口机 ...