Write a spell checking tool that will identify all misspelled word in a text file using a provided dictionary.


The program will accept either one or two command line parameters.
1. The first command line parameter is the name of the text file that will be checked.
2. The optional second command line parameter is the name of the dictionary file – a file of words with one word per line. The default dictionary file is ref.txt.
The program will write out the misspelled words, one per line, in alphabetical order.

Extend the spell checking tool so that as well as identifying all misspelled words, the program will list the line numbers in the file where the incorrect spelling occurs.
The program will write out the misspelled words (one per line, in alphabetical order), followed by a tab character, followed by the list of line numbers in ascending order, on the same line, separated by a single space.

Please Help!!!

This file name is usrinput.py

#! /usr/bin/env python

import sys
import os

This file name is allfunction.py
#! /usr/bin/env python

import os
import string

def readfile(filename):
try:
fd=open(filename,'r')
try:
for eachline in fd.readlines():
# delete all
lis=string.strip(eachline)
lis=lis.split()
#print lis
for eachword in lis:
print eachword
lower(eachword)
#print lis[eachword]
#print "\t"

finally:
fd.close()
except IOError:
pass

def lower(word):
if word !=None:
string.lower(word)
print "lower string===",string.lower(word)
if __name__=="__main__":
filename='utpal.txt'
readfile(filename)

and last one is dictionary utpal.txt

utpal working in
busy with
spell check

Now go through first two file u will get result soon.


def usage():
print 'Minimum 3 arguments are required'
#print 'usage: args.py arg1 arg2 [arg3... ]'
#Total No of agrument
print "number of args entered:", len(sys.argv)
#The Arguments are
print "args (incl. cmd name) were:", sys.argv
sys.exit(1)

def takeinput():

argc= len(sys.argv)
if argc < 2:
print 'Give proper value'
usage()
#check for file extension or file format
(name,ext)=os.path.splitext(sys.argv[1])
if ext !=".txt":
print 'Enter proper file for spell check'
else:
#pass
if os.path.isfile(sys.argv[1]):
make='-chk'
(name,ext)=os.path.splitext(sys.argv[1])
name=name + make
name=name + ext
print name
else:
print 'File Not exist'
sys.exit(1)
if __name__=="__main__":
takeinput()

Hello it's mingle the order which i post so i mention the file name and co-respondent function
allfuction.py--------------- readfile and lower and main
usrinput.py(this main file) --usage and takeinput and main
and utpal.txt it my dictionary use can change it put correct word actually from this file spell will check that user data is wrong or not.

Write a spell checking tool that will identify all misspelled word in a text file using a provided dictionary.


The program will accept either one or two command line parameters.
1. The first command line parameter is the name of the text file that will be checked.
2. The optional second command line parameter is the name of the dictionary file – a file of words with one word per line. The default dictionary file is ref.txt.
The program will write out the misspelled words, one per line, in alphabetical order.

Extend the spell checking tool so that as well as identifying all misspelled words, the program will list the line numbers in the file where the incorrect spelling occurs.
The program will write out the misspelled words (one per line, in alphabetical order), followed by a tab character, followed by the list of line numbers in ascending order, on the same line, separated by a single space.

Please Help!!!

Since this is homework, you need to show some coding effort of your own first.

HINT ...
you have to split the text into words and compare them withe words in the dictionary.

to continue from vegaseat's hint:

...and you must deal with punctuation being put together with previous/following word.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.