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
}
}
Spell checker using hash table的更多相关文章
- 散列表(hash table)——算法导论(13)
1. 引言 许多应用都需要动态集合结构,它至少需要支持Insert,search和delete字典操作.散列表(hash table)是实现字典操作的一种有效的数据结构. 2. 直接寻址表 在介绍散列 ...
- 哈希表(Hash Table)
参考: Hash table - Wiki Hash table_百度百科 从头到尾彻底解析Hash表算法 谈谈 Hash Table 我们身边的哈希,最常见的就是perl和python里面的字典了, ...
- Berkeley DB的数据存储结构——哈希表(Hash Table)、B树(BTree)、队列(Queue)、记录号(Recno)
Berkeley DB的数据存储结构 BDB支持四种数据存储结构及相应算法,官方称为访问方法(Access Method),分别是哈希表(Hash Table).B树(BTree).队列(Queue) ...
- 几种常见 容器 比较和分析 hashmap, map, vector, list ...hash table
list支持快速的插入和删除,但是查找费时; vector支持快速的查找,但是插入费时. map查找的时间复杂度是对数的,这几乎是最快的,hash也是对数的. 如果我自己写,我也会用二叉检索树,它在 ...
- PHP内核探索之变量(3)- hash table
在PHP中,除了zval, 另一个比较重要的数据结构非hash table莫属,例如我们最常见的数组,在底层便是hash table.除了数组,在线程安全(TSRM).GC.资源管理.Global变量 ...
- php Hash Table(四) Hash Table添加和更新元素
HashTable添加和更新的函数: 有4个主要的函数用于插入和更新HashTable的数据: int zend_hash_add(HashTable *ht, char *arKey, uint n ...
- php Hash Table(一) Hash Table的结构
关于Hash Table专题: 一直想深入理解一下php的hash table的实现,以前一直是星星点点的看看,从未彻底的总结过,那就从这个专题开始吧! 主要想总结几个部分:hashtable结构,h ...
- Spell checker
Spell checker Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Subm ...
- Hash Table 的实现步骤是什么
什么是HashTable Hash Table 是计算机科学中很重要的一种数据结构,其时间复杂度为O(1),主要是通过把关键字Key 映射到数组中的一个位置来访问记录,所以速度相当快.映射函数称为 H ...
随机推荐
- Codeforces 979E Kuro and Topological Parity - 动态规划 - 组合数学
题目传送门 传送点 题目大意 给定$n$个标号依次为$1, 2, \cdots, n$的点,其中一些点被染成一些颜色,剩下的点没有染色.你需要添加一些有向边并将剩下的点染色,满足有向边从编号小的一端指 ...
- linux PWM蜂鸣器移植以及驱动程序分析【转】
本文转载自:https://blog.csdn.net/lxllinux/article/details/80885331 一.关于PWM: PWM(Pulse Width Modula ...
- linux下如何源码编译安装vim
1. 获取源码 git clone https://github.com/vim/vim.git ~/vim cd ~/vim 2. 配置 ./configure --prefix=/home/jel ...
- $O(n+log(mod))$求乘法逆元的方法
题目 LOJ #152. 乘法逆元 2 题解 一个奇技淫巧qwq.可以离线求乘法逆元,效率\(O(n+log(mod))\). 考虑处理出\(s_n\)表示\(\prod_{i=1}^na_i\).以 ...
- SQL Developer连接Oracle出现“IO 错误:Undefined Error”
1.环境 Win 10系统 Oracle 11 g R 2 JDK 1.8.0_152 SQL Developer-17.2.0 2.安装完成后,运行SQL developer,选择JDK路径,连接出 ...
- Font Awesome字体图标的 用法, 很简单
http://fontawesome.dashgame.com/ 上面是 官网, 可下载,也可以CDN. 1... 加载 2... 用法
- Cordova结合Vue学习Camera
简单聊两句 学习Vue+Cordova打包编译App,首先你要安装Cordova与vue,在这里本人就不说明了,自行看文档与搜索相关资料. Cordova中文官网地址 Vue中文官网地址 第一步:首先 ...
- Token国内地铁使用城市
天津 广州 深圳 南京 武汉 台北 高雄
- 『流畅的Python』第1~4章笔记_数据结构、编码
由于1~4章内容零散且基础,所以统计一下涉及到的内容,记录一下,方便查阅(第一张图右键新页面打开即可看到清晰大图)
- 【转】Ubuntu英文系统下安装中文输入法
转自:https://my.oschina.net/No5stranger/blog/290026 ubuntu默认的输入法是ibus,综合网上评论,fcitx的支持者更多,而且个人感觉fcitx也的 ...
