spell checker script

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions spell checker script
# 1  
Old 11-10-2010
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 contains. For each word that is found to be incorrect, the invoker is asked for either:
  • to insist on the spelling of the word.
  • to provide a replacement spelling
If the invoker insists on the spelling of the word, then niuspell will remember it. niuspell remembers words in the file ".niuspelled" in the invoker's home directory. Any further invocation of niuspell by the same invoker will consider the word to be correct. Otherwise, the invoker is prompted for a replacement spelling. As output, niuspell produces a 2-column-ed list of words, the left column lists incorrectly spelled words, the right column lists their replacement as given by the invoker. The list is produced after the invoker has answered to all incorrectly spelled words....



Everything works fine except the "insisted on words" appear in the "misspelled" column after the first invocation and they are not supposed to. The subsequent invocations don't list the insisted on words in the column, just the actual misspelled words. Any help will be appreciated.




2. Relevant commands, code, scripts, algorithms:



3. The attempts at a solution (include all code and scripts):
Code:
!# /bin/bash

#variables
corSpel=()
let count=1

#array for spell checker
checker=(`ispell -l -p ~/.checked < $1`)

echo ""

#for loop to correct mispelled words
for i in ${checker[*]}; do
        read -p "$i is mispelled. Press \"Enter\" to keep
this spelling, or type a correction here: " corIn
        if [[ "$corIn" = "" ]] ; then
                echo $i >> ~/.niuspelled
        else
                corSpel[$count]=$corIn
        fi
 count+=1
echo ""
done

#for loop to print the corrected words
printf "MISPELLED %20s\n" CORRECTIONS
echo ""
let counter=1
for i in ${checker[*]}; do
        printf "%-20s%s\n" "$i" "${corSpel[$counter]}"            
 counter+=1
done

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Northern Illinois University, Mr. Ege, csci 330

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 12-05-2010
When they "insist" on a word you don't assign the corSpel array, so this is your clue (corSpel[counter] is blank), add a test for this when outputting your corrections.
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. Shell Programming and Scripting

IP list specific port checker script

Hello again people, I currently searching for a code/script that will allow it to check if a specific port is open, lets say 123. Found a public script on a ftp but I dont know how and what to modify in it to suit my needs. (I think this is a evil code and I want to use it as an example). ... (3 Replies)
Discussion started by: galford
3 Replies

3. 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

4. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: DsmRacer2k14
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

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

8. UNIX for Advanced & Expert Users

spell

Hi, I found the following line in a shell script. $spell -a < $filename | \ grep -v '@(#)' | sed "s/\'//g" | \ awk '{ if (length($0) > 15 && length($2) > 2) print $2 }' | \ grep -vif $okaywords | \ grep ']' | grep -v ']' | sort -u | \ sed 's/^/ /' > $tempout can... (2 Replies)
Discussion started by: ravi raj kumar
2 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