Help with Bash Shell Script Spell Checker program.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with Bash Shell Script Spell Checker program.
# 1  
Old 10-20-2014
Help with Bash Shell Script Spell Checker program.

I have a majority of this problem done but seem to be struggling on the last couple of steps. Here is the whole problem to help you guys get a better understanding.

Write a shell script that implements a simple spell checker.
The filename you will use for your script will be your Z-id followed by “.spell”. For example, if your Z-id is
“z123456” then your script must be called “z123456.spell”.
The script will be invoked as:

Code:
% z123456.spell file

You are encouraged to take advantage of the “aspell list” command. It produces a list of misspelled words from
standard input.

When your script is invoked from the command line it reads “file” and checks each word it contains for proper
spelling. For each word that is found to be incorrect, the invoker is asked to either:

• confirm that the spelling used was as intended (no changes made)
• provide a replacement spelling for the word

If the invoker chooses the first option and confirms that the spelling was intended, the script will “remember”
it. Your script will “remember” words in the “∼/.memory” file.If the invoker chooses the first option and confirms that the spelling was intended, the script will “remember”
it. Your script will “remember” words in the “/.memory” file.
If not, the invoker will be prompted for a replacement spelling. As output, your script will produce a two columned
list of words. The left column lists incorrectly spelled words, and the right column lists their replacement
as given by the invoker. The list is produced after the invoker has chosen a response for all incorrectly spelled
words.


Example run through...

Code:
% ls
testfile z123456.spell
% cat testfile
In navigation, a vehicle’s course is the agle that the intended
path of the vehicle makes with a fixed reference objekt
(typically truenorth). Course is measured in degrees from 0
clockwise to 360 in ECMD compass convention (0 being north,
90 being east). Course is customarily expressed in three
digits, using preliminary zeros if needed.
% ./z123456.spell testfile
’agle’ is mispelled. Press "Enter" to keep
this spelling, or type a correction here: angle
’objekt’ is mispelled. Press "Enter" to keep
this spelling, or type a correction here: object
’truenorth’ is mispelled. Press "Enter" to keep
this spelling, or type a correction here:
’ECMD’ is mispelled. Press "Enter" to keep
this spelling, or type a correction here:
MISPELLED: CORRECTIONS:
agle angle
objekt object
% ./z123456.spell testfile
’agle’ is mispelled. Press "Enter" to keep
this spelling, or type a correction here: angle
’objekt’ is mispelled. Press "Enter" to keep
this spelling, or type a correction here: object
MISPELLED: CORRECTIONS:
agle angle
objekt object
% cat ˜/.memory
truenorth
ECMD
% cat testfile
In navigation, a vehicle’s course is the agle that the intended
path of the vehicle makes with a fixed reference objekt
(typically truenorth). Course is measured in degrees from 0
clockwise to 360 in ECMD compass convention (0 being north,
90 being east). Course is customarily expressed in three
digits, using preliminary zeros if needed.

Your script must have /bin/bash in its shebang line.
Make sure that your script does not leave any temporary files behind.


Okay so this is what I have so far. I was just done to the last two steps of getting the two misspelled words to print correctly into an array or something that's easier then that. The next step would be being able to have the bash file read the memory file so It does not ask for those two misspelled words you press enter into when you run the program a 2nd time through. Any help is great or a better way (and easier) is much appreciated!

Code:
#! /bin/bash

for i in `aspell list < testfile`
do

	if [ i="" ]; then        
	
	read -p "'$i' is mispelled. Press \"Enter\" to keep this spelling, or type a correction here: " check; 
	#echo $check;
	fi

#echo $check;
	if [ "$check" = "" ]; then
	echo "$i" >> memory;
	#elif [ "$check" != "" ]
	#then
		#array[2]= "$check";
	#echo ${array[@]}
	fi




done

echo "MISPELLED           CORRECTIONS"
#printf "array[]";
echo "objekt                 object"


The echo on the end is just an example of what the output should look like. and the commented out parts are some ideas I had that I could not get to work yet or might just get rid of them all together.
# 2  
Old 10-20-2014
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help Needed with File Checker Korn Shell Script

I am attempting to write a korn shell script that does the following, but I am getting errors. I'm new to korn shell scripting and am not sure what I am doing wrong. Please help with example scripts. Thanks. 1) check for day of the week 2) if day of the week is Monday then check for the... (4 Replies)
Discussion started by: ijmoore
4 Replies

2. Debian

Getting a better spell checker

Guys I am new to Linux in general and want to know what is the use of the following files-: /usr/share/dict/words /usr/share/dict/words.pre-dictionaries-common Are they used by the spell checker to find potential typos ? If so are there any better larger word lists out there ? I am sure... (2 Replies)
Discussion started by: sreyan32
2 Replies

3. Shell Programming and Scripting

Problem with bash shell script program

Hi, This is my program. #!/bin/bash today=`date +"%b-%d-%Y"` SERVICE="pbxconnect.php" if ; then echo "pbx program is running" else nohup php pbxconnect.php > logpbx-$today.txt & fi On executing using "sh myprogram.sh" , i get the following error. myprogram.sh: line 4: ' My... (7 Replies)
Discussion started by: gskumar1234
7 Replies

4. Homework & Coursework Questions

spell checker script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: When "niuspell" is invoked from the command line it reads "file" and checks it for spelling of the words it... (1 Reply)
Discussion started by: Jeffthrow5
1 Replies

5. Homework & Coursework Questions

Unix Spell Checker Assignment

hello, im a new member to the forum and im doing a assignment for unix command and we have to make a spell checker and im a little confused about the directions .. ill post them below and continue.. Northern Illinois University CSCI 330-Unix Command Write a shell script that implements a... (1 Reply)
Discussion started by: bravens52
1 Replies

6. Shell Programming and Scripting

Need your help for the spell checker in unix or python

Hi, Want to know is there any command to correct the spelling using unix or python? Unix command "spell" will give only the list of the incorrect words . But i want the output along with the corrected word . Thanks in advance (1 Reply)
Discussion started by: vini
1 Replies

7. Shell Programming and Scripting

spell check program

hi, i need to write a spell check program in bash to find all possible spelling errors in a file or a number of files taken as input using usr/dict/words. whenever the program encounters a spelling error, it must state the line number at which the incorrect spelling has occured and... (1 Reply)
Discussion started by: kratos.
1 Replies

8. Shell Programming and Scripting

Shell Sript - Spell Checker Assign

Hi Folks. I am currently working on a script that has to spell check a file and print the output to the screen in 2 columns like this. INCORRECT CORRECTION whio who weahter weather The file will allow the user to override the ispell command and save any... (9 Replies)
Discussion started by: ccfc1986
9 Replies

9. Shell Programming and Scripting

spell checker program

2.I need shell script to list all the 'words' in a given file (text) that are not listed in a specified dictionary. Let us call this utility 'spell-check'. 'spell-check' will be called as follows. $ spell-check letter Lucent UNIX UNIX OS a $ dictionary words are listed in lower... (2 Replies)
Discussion started by: ksjanakan
2 Replies

10. Shell Programming and Scripting

Shell script syntax checker

I have a rather big script that i have written in ksh and it is falling over in two places with a 'test argument' error. I know this usually means that the if statement is not correct, but it is fine. I have looked through the rest of the script for any odd brackets or ` marks, but can't see... (2 Replies)
Discussion started by: handak9
2 Replies
Login or Register to Ask a Question