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 ...
随机推荐
- JavaScript if 条件语句
JavaScript if 条件语句 使用: if(条件){ }else if(条件){ }else if(条件){ }else{ } 示例: // 判断相等 if(1==1){ } // 判断不等 ...
- [c/c++] programming之路(14)、数组+冒泡和选择排序
一.数组的基本知识 #include<stdio.h> #include<stdlib.h> void main0(){ ]={,,,,};//数组在内存里是连续排列的 int ...
- 剑指offer(11)二进制中1的个数
题目描述 输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. 题目分析 首先我们要了解计算机中负数使用补码表示的,原码.补码的概念以及原理可以参考这里,这个题目我们应该从二进制入手,值得 ...
- C++读写图片数据转成Base64格式的一种方法
最近在一个项目中要实现在客户端和服务端之间传送图片文件的功能,采用了C++语言读写图片转化成Base64格式进行传输.具体代码如下: //++Base64.h #pragma once class C ...
- CMS GC启动参数优化配置
简介: java启动参数共分为三类: 其一是标准参数(-),所有的JVM实现都必须实现这些参数的功能,而且向后兼容: 其二是非标准参数(-X),默认jvm实现这些参数的功能,但是并不保证所有jvm实现 ...
- iconfont作用在css伪类中的写法
iconfont作用在css伪类中需要注意两点: 1.字体声明(font-family: "iconfont";). 2.把字体写成十六进制的Unicode编码.比如:" ...
- [Oracle11g] 通过伪列查询
oracle中的伪列默认第一行是1,所以可以选择<=rownum的方法选取,但是>是无法选取的.这时候需要固化伪列. 固化前可以这样查询:select * from 表名 where r ...
- iSCSI网络协议.学习笔记
Internet SCSI(iSCSI)是一种网络协议,使用TCP/IP网络来传输SCSI协议.它是代替FC(Fibre Channel-based,光纤通道) SAN的很好选择.你可以在Linux下 ...
- 版本控制工具Git的复杂用法的情境分析
Git的版本库中的文件的三种状态 对于任何一个文件,在 Git 内都只有三种状态: 已提交(committed),已修改(modified)和已暂存(staged). 已提交表示该文件已经被安全地保存 ...
- 『TensorFlow』从磁盘读取数据
十图详解TensorFlow数据读取机制 一.输入流水线读取数据流程 1). 创建文件名列表 相关函数:tf.train.match_filenames_once 2). 创建文件名队列 相关函数:t ...
