Compare commits

...

5 Commits

Author SHA1 Message Date
HeroOfTheWinds 5f90f4353c V2 complete! 2016-02-04 09:51:27 -10:00
Chris N fe8d6cbb3a Fix doubled code
Stupid boy is stupid.
2016-02-03 18:23:00 -10:00
Chris N d4ea0a0dcf Use arrays, ADD works right.
Make sure to run with bash, not sh.
2016-02-03 18:09:44 -10:00
Chris N f2b2be4281 Closer to actual product
Has nasty input error, user can't enter options.  Exploring solutions...
2016-02-03 15:08:48 -10:00
Chris N 3256560d0e Add functionality to read file word by word 2016-02-03 14:20:33 -10:00
2 changed files with 99 additions and 0 deletions

41
SpellCheckerv1.sh Normal file
View File

@ -0,0 +1,41 @@
#!/bin/bash
echo "Enter name of file to check:"
read fname
#Make array to hold words
words=()
#Check if dictionary file exists yet
if [ ! -f CABSC.dict ]
then
echo "" > CABSC.dict
fi
#Read file line by line
while read line
do
#Read each word on line
for word in $line
do
words+=("$word")
done
done < $fname
for word in ${words[@]}
do
if ! grep $word "CABSC.dict" > /dev/null
then
echo $word is not in dictionary
echo "Would you like to add it? <y/n>"
read ans
while [ $ans != "y" -a $ans != "n" ]
do
echo y or n only
read ans
done
if test $ans == "y"
then
echo $word >> CABSC.dict
fi
fi
done

58
spellcheckerv2.sh Normal file
View File

@ -0,0 +1,58 @@
#!/bin/bash
echo "Enter name of file to check: "
read fname
# Make array to hold words
words=()
#Check if dictionary file exists yet
if [ ! -f CABSC.dict ]
then
echo "" > CABSC.dict
fi
#Read file line by line
while read line
do
#read each word on line
for word in $line
do
words+=("$word")
done
done < $fname
for word in ${words[@]}
do
if ! grep $word "CABSC.dict" > /dev/null
then
echo $word is not in dictionary
echo "Would you like to add it? <y/n>"
read ans
while [ $ans != "y" -a $ans != "n" ]
do
echo y or n only
read ans
done
if test $ans == "y"
then
echo $word >> CABSC.dict
fi
echo "Would you like to change the spelling of the word? <y/n>"
read ans
while [ $ans != "y" -a $ans != "n" ]
do
echo y or n only
read ans
done
if test $ans == "y"
then
echo "What is the new spelling?"
read new_word
ed = $fname <<!
g/$word/s//$new_word/g
w
q
!
fi
fi
done