Spell Check
来源:互联网 发布:mac倩女幽魂手游 编辑:程序博客网 时间:2024/05/17 01:58
http://programarcadegames.com/index.php?chapter=lab_spell_check
Requirements
Write a single program in Python that checks the spelling of the first chapter of “Alice In Wonderland.” First use a linear search, then use a binary search. Print the line number along with the word that does not exist in the dictionary.
Follow the steps below carefully. If you don't know how to accomplish one step, ask before moving on to the next step.
import redef split_line(line): return re.findall('[A-Za-z]+(?:\'[A-Za-z]+)?',line)file=open("dictionary.txt")dictionary_list = []for line in file: line = line.strip() dictionary_list.append(line) print( "There were",len(dictionary_list),"names in the file.")file.close()print("---Liner Search---")file = open("AliceInWonderLand200.txt")words = []for line in file: word_line = split_line(line) for l in word_line: word = split_line(l) words.append(word) print(words)for i in words: for j in dictionary_list: if words[i] == str(dictonary_list[j]): break print("Line",i,"possible misspelled word:",words[i])
还是错的。。。
报错:
Traceback (most recent call last):
File "E:\python\text\text.py", line 30, in <module>
if words[i] == str(dictonary_list[j]):
TypeError: list indices must be integers, not list
- Spell Check
- spell check investigation
- [solr] - spell check
- [solr] - spell check
- 给solr加spell check
- Peter Novig Spell Check http://norvig.com/spell-correct.html
- POJ 1035 Spell Check 字符串处理
- VIM学习笔记 拼写检查(Spell Check)
- vim Linux environment cannot add words for spell check
- Visual Assist X设置-去除spell check错误的下划线
- OS X:禁止/准许输入拼写检查(Spell Check While Typing)
- check
- CHECK
- Spell checker
- Spell Checker
- Spell Checker
- Spell checker
- Spell Checker
- Java面试宝典2013版(超长版)
- vim自动缩进
- Centos6.4下安装mplayer的整个过程
- GDB的基本工作原理剖析
- gdb命令手册
- Spell Check
- 用GDB调试程序
- CentOS6.3安装VLC
- 关于安装reaver出错到处理
- 那时候,你喜欢……
- 最色情的考题,最强的学生
- 九个寓言故事揭示泡妞成功秘技
- CentOS 6.4超级终端minicom的使用方法 以及lrzsz
- CentOS6.4下利用dnw烧写文件,dnw安装与配置(基于TQ2440)