编程练习:Spell checker

ayit第十六周训练题a题 You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words in all their forms. If the word is absent in the dictionary then it 阅读详情

http://poj.org/problem?id=1035


Description


You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words in all their forms. 
If the word is absent in the dictionary then it can be replaced by correct words (from the dictionary) that can be obtained by one of the following operations: 
?deleting of one letter from the word; 
?replacing of one letter in the word with an arbitrary letter; 
?inserting of one arbitrary letter into the word. 
Your task is to write the program that will find all possible replacements from the dictionary for every given word. 
Input


The first part of the input file contains all words from the dictionary. Each word occupies its own line. This part is finished by the single character '#' on a separate line. All words are different. There will be at most 10000 words in the dictionary. 
The next part of the file contains all words that are to be checked. Each word occupies its own line. This part is also finished by the single character '#' on a separate line. There will be at most 50 words that are to be checked. 
All words in the input file (words from the dictionary and words to be checked) consist only of small alphabetic characters and each one contains 15 characters at most. 
Output


Write to the output file exactly one line for every checked word in the order of their appearance in the second part of the input file. If the word is correct (i.e. it exists in the dictionary) write the message: " is correct". If the word is not correct then write this word first, then write the character ':' (colon), and after a single space write all its possible replacements, separated by spaces. The replacements should be written in the order of their appearance in the dictionary (in the first part of the input file). If there are no replacements for this word then the line feed should immediately follow the colon.
Sample Input


i
is
has
have
be
my
more
contest
me
too
if
award
#
me
aware
m
contest
hav
oo
or
i
fi
mre
#
Sample Output


me is correct
aware: award
m: i my me
contest is correct
hav: has have
oo: too
or:
i is correct
fi: i
mre: more me
Source


思路:

根据字典创建 TrieTree, 而后在 TrieTree 执行 mach rule

到没有找到匹配的时候:

?deleting of one letter from the word; 

tree 中直接找到下一个字母,记录单词,并设计 fault_count =1 


?replacing of one letter in the word with an arbitrary letter; 

tree 中随便找一个字母作为下一个,记录单词,并设计 fault_count =1 


前两条 false_count = 2 就舍弃


?inserting of one arbitrary letter into the word. 

(这条规则不好办...)  

枚举单词间隔加入一个字母(新单词有mx26个,m为字母间隔),而后搜索 trietree , 必须完全匹配





STK传感器约束设置保姆级教程:从方位角到传播延迟,手把手教你避开新手常见坑 本文详细解析了STK传感器约束设置的关键技巧,涵盖方位角、仰角、高度及传播延迟等核心参数。通过实战案例和代码示例,指导用户避开常见误区,优化卫星通信和航天任务仿真精度,特别适合STK新手和需要提升传感器配置效率的工程师。 阅读详情

相关推荐

INCA软件操作指南:手把手教你生成和解析DCM标定数据文件

本文详细介绍了INCA软件在汽车ECU开发中生成和解析DCM标定数据文件的全流程。从A2L文件导入到DCM文件生成,再到HEX文件导出,手把手教你掌握标定数据处理的实用技巧,包括参数标定、曲线标定和常见问题排查,帮助工程师提升工作效率。

weixin_29271053的博客 1093

1035 Spell checker

<br />Spell checkerTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 10052 Accepted: 3713<br />DescriptionYou, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words

hqd_acm的专栏 1015

用STM32F103C8T6和TB6612驱动模块,从零搭建一辆能避障循迹的智能小车(附完整代码)

本文详细介绍了如何使用STM32F103C8T6和TB6612驱动模块从零搭建一辆能避障循迹的智能小车。内容涵盖硬件选型、电路设计、底层驱动配置以及智能行为算法实现,并附有完整代码示例,帮助开发者快速掌握嵌入式开发的核心技术。

weixin_42641741的博客 453

C. Spell Checker

思路:这个题wa到自闭,不过还好最后做出来了,就暴力枚举一下字典中的每一个单词,注意一下,置换这个操作就行,举个例子 thu和 tuh是置换thu和tug不是置换 code; #include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N=110; string s[N]; int main() { int d,n; cin&gt...

qq_44797733的博客 361

开关电源设计实战:如何用AP值快速选型磁芯(附计算公式推导)

本文为开关电源工程师提供了基于AP值的磁芯快速选型实战指南。文章深入解析了AP值作为磁芯‘功率吞吐量’指标的核心物理意义,并通过详细的公式推导和24W反激电源设计实例,手把手演示如何利用AP值计算公式,结合电流密度、窗口利用率等关键参数,从众多磁芯型号中高效筛选出合适型号,同时强调了选型后的关键校验步骤与常见误区。

weixin_29234239的博客 909

(6)NUC980 SPI Nand 启动

方式一:下载到SPI-NAND-Flash中,这种方式可以将程序固化到SPIflash中,可以掉电保存。第二种方式下载到DDR中程序掉电丢失,但是DDR调试方便,时候调试的时候使用。之前的设置都是基于SD卡启动,今天测试一下是用SPI flash启动。方式二: 下载到DDR中,①设置为USB启动②下载到DDR中③运行。1:烧写BootLoader。

卤煮小鱼的博客 1768

C语言实现拼写检查器(C-Spellchecker)

    原题目连接:Implementations of a Spell Checker     C-Spellchecker实现 Introduction You will create a very basic spell checker. Your program will read the “dictionary” (list of words) into a Set, then

不善挽留 1772

EtherCAT学习之路——概述

首发于知乎 最近在做基于EtherCAT的项目,看了一些网上的博客,感觉写的都比较松散。虽然,自己也是才开始学习,希望能把这段时间学到的东西总结一下。 1.EtherCAT简介 EtherCAT是由德国BECKHOFF自动化公司于2003年提出的实时工业以太网技术。它具有高速和高数据有效率的特点,支持多种设备连接拓扑结构。其从站节点使用专用的控制芯片,主站使用标准的以太网控制器。 Et...

chenweizhen1991的博客 1万+

POJ 1035:Spell checker

Spell checker Time Limit:2000MS Memory Limit:65536K Total Submissions:22574 Accepted:8231 Description You, as a member of a development team for a new s...

weixin_34315665的博客 159

使用ArcGIS Pro进行土地利用分类的机器学习与深度学习

传统的土地利用分类方法通常依赖于手动解译和规则定义,但随着机器学习和深度学习的发展,我们现在可以利用这些技术来自动化和提高分类的精度。ArcGIS Pro是一种功能强大的GIS软件,它提供了丰富的工具和功能,可以支持土地利用分类的机器学习和深度学习。我们将首先讨论数据准备和预处理的步骤,然后介绍常用的机器学习和深度学习方法,并提供相应的源代码示例。这可以通过人工标注或半自动的方式完成。数据裁剪:根据研究区域的范围,裁剪遥感影像数据,以减少计算和存储的负担,并确保只包含感兴趣的土地利用区域。

code_program481的博客 2047

PCL 快速均匀下采样

快速均匀下采样 是一种点云降采样技术,通过设置采样步长来实现等距降采样,从而减少点的数量。用户可以通过指定步长,选择每隔一定数量的点采样一个点,这样可以在保持点云几何特性的同时,显著减少点的数量。

纵马踏花向自由 875

VS Code Code Spell Checker 插件详解

Code Spell Checker 提供了丰富的配置选项,可以通过 VS Code 的设置 (Ctrl+,或Cmd+,) 进行修改,推荐直接编辑文件。以下是常用的配置示例:json// 设置要检查的语言// 添加自定义单词(全局)// 添加工作区特定单词// 忽略的单词// 启用检查的文件类型"html","python"],// 忽略的文件路径// 启用复合词你也可以在项目根目录创建文件进行项目级配置,建议通过.gitignore忽略该文件,使其仅在本机生效。

BillKu的博客 1912

麒麟服务器操作系统QT系列软件工具手册

对Qt提供的开发工具进行了一系列的优化之后,在日常的修复bug和维护框架的过程中,桌面研发对Qt的基础软件库也进行了部分优化工作,包括qtbase、qtwayland、qtscript、qt4-x11等Qt基础组件,涉及的Qt框架版本主要涉及到5.9和5.12两个版本。qt 的翻译,是由 ts 文件生成 qm 文件然后进行翻译,国产操作系统上qt 的翻译是由单独的qttranslations包中进行维护,其次部分汉化问题也是qt组件维护工作的一部分,qt的翻译机制如图4-7所示。

太极淘的博客 547

(7)VSCode - 好用的5大插件安装、Fitten Code插件、ChatGPT插件、GitLens插件、Code Spell Checker插件《小鹅说 C 语言》

Fitten Code是由非十大模型驱动的 AI 编程助手,它可以自动生成代码,提升开发效率,帮您调试 Bug,节省您的时间,另外还可以对话聊天,解决您编程碰到的问题。如果母语不是英语,或者你虽然是英语母语国家的人,但拼写不好,那么 Code Spell Checker 可是能帮你好大的忙,尤其是在输入变量名的时候。它能够高亮代码中的拼写错误,并且支持自定义词典,可以忽略你认为是对的单词,还可以选择不同的词典。这个时候,你就可以用 Peacock 为不同的项目更改窗口的主题颜色,还是蛮实用的。

小鹅系列笔记 2239

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

推荐项目:Comment Spell Checker - 代码注释的拼写守护者

推荐项目:Comment Spell Checker - 代码注释的拼写守护者 在编程的世界里,清晰准确的注释是沟通代码意图的关键。然而,拼写错误却常常成为开发者的小尴尬。今天,我们要推荐一个神器——Comment Spell Checker,它专为解决这一痛点而来。 项目介绍 Comment Spell Checker 是一款高效实用的Xcode源码编辑器扩展工具,旨在运行拼写检查和自动纠错功...

gitblog_00623的博客 832

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Vim中的拼写检查利器:Coc-Spell-Checker

Vim中的拼写检查利器:Coc-Spell-Checker 在编程过程中,文字错误可能会给代码的可读性和理解带来困扰,尤其是在文档和注释中。为此,我们向你推荐一款专为(Neo)Vim打造的高效拼写检查插件——Coc-Spell-Checker。它是从VSCode Spell Checker项目的基础上fork并优化而来,特别针对camelCase编码风格进行了调整,以减少误报。 项目简介 Coc-...

gitblog_00045的博客 486

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

vscode-spell-checker:提升代码质量的终极源代码拼写检查工具

在软件开发过程中,代码中的拼写错误可能导致难以追踪的bug、降低代码可读性,甚至影响团队协作效率。vscode-spell-checker作为一款专为源代码设计的拼写检查工具,能够无缝集成到Visual Studio Code环境中,帮助开发者在编码过程中实时检测并修正拼写问题,是提升代码质量的必备工具。 [![vscode-spell-checker标志](https://raw.gitcod

gitblog_00969的博客 362

vscode-spell-checker核心功能全解析:让你的代码远离拼写错误

vscode-spell-checker是一款专为代码开发打造的拼写检查工具,它能够实时检测代码中的拼写错误,帮助开发者避免因拼写问题导致的bug和尴尬。无论是变量名、注释还是字符串,这款工具都能精准识别并提供修正建议,让你的代码更加专业和可靠。 ## 为什么选择vscode-spell-checker? 在软件开发过程中,拼写错误看似小事,却可能导致严重的后果。比如变量名拼写错误可能导致程序

gitblog_00467的博客 519

发现更好的代码拼写检查工具:从退役的Spell and Grammar Checker看向前方

发现更好的代码拼写检查工具:从退役的Spell and Grammar Checker看向前方 在快速迭代的技术世界里,每个工具都有它的生命周期。【已弃用】的Spelling and Grammar Checker,尽管其服务基础已不再稳定,尤其是对英语用户的完全影响,但这并不意味着我们失去了优质的代码拼写检查支持。相反,这一变化为我们提供了一个升级换代的契机。 技术更新,体验更佳 对于开发者而言...

gitblog_01117的博客 390

Spell checker(字符串练习)

  Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct wo...

PleasantlY1的博客 593

POJ 1035 Spell checker

Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15145   Accepted: 5504 Description You, as a member of a development team for a new spell checkin

ACM2272902662的专栏 751

POJ 1035: Spell checker

题目来源:http://poj.org/problem?id=1035Spell checkerTime Limit: 2000MS Memory Limit: 65536K Total Submissions: 27099 Accepted: 9915 DescriptionYou, as a member of a development team for a newspell ...

da_kao_la的博客 352

POJ1035——Spell checker

POJ1035——Spell checker /* *********************************************************** 算法原理: 错误有三种情况 1)少一个字母 2)多一个字母 3)其中一个字母被替换 ①首先,如果|word.length() - dictionary.length()|> 1 就跳过dictionary中的

zykimmy的博客 467

poj 1035 Spell checker

点击打开链接 Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16970   Accepted: 6223 Description You, as a member of a development team for a n

云淡风清 777

Xcode代码注释拼写检查扩展——Comment-Spell-Checker

Xcode代码注释拼写检查扩展——Comment-Spell-Checker 1. 项目基础介绍 Comment-Spell-Checker 是一个开源的Xcode扩展项目,主要用于在Xcode开发环境中对代码注释进行拼写检查和自动更正。该项目使用Swift语言开发,旨在提高开发者的代码质量和工作效率。 2. 核心功能 支持多种注释风格:该扩展支持包括 //、///、/* ... */、/** ...

gitblog_00422的博客 485

S - Spell checker

题目描述: You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words in all...

年轻过成了秃顶 359
上一篇: ubuntu 运行 usb camera
下一篇: 编程练习:Biorhythms
span76
博客等级 码龄18年 117粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值