Sponsored Content
Full Discussion: Writing a script for aspell
Homework and Emergencies Homework & Coursework Questions Writing a script for aspell Post 302865891 by gamernerd101 on Sunday 20th of October 2013 10:38:25 AM
Old 10-20-2013
Thanks so much, that makes much more sense. However, I'm still getting the same problems. I've tried multiple different variants of my loop. It seems to me that I may be storing it wrong? Maybe I am still trying to loop through the arrays wrong but here's what else I tried and has only accessed the first string of misspelled words. (Along with this one.)

Code:
for i in "${uncorrect[@]}"; do
for j in "${reSpell[@]}"; do
printf $i "" $j

This did not access the strings I believe I stored in the corresponding arrays, so maybe my problem is storage. Thanks again.

Code:
#! /bin/bash

reSpell=()
uncorrect=()
# now check the spellings
let count=1

check=(`aspell list -p ~/.checked < $1`)
# for each mispelled word in the file is entered into i and put into the new directory memory if corrected
for i in ${check[*]} ; do
   uncorrect[$count]=$i
   read -p "$i is mispelled. Press \"Enter\" to keep this spelling or type your new spelling here: " newSpell

   # unfixed spellings are ignored and not replaced and are left where they are in the fiexedspell array
if [ "$newSpell"="" ]; then
   echo $i>> ~/.memory

else
   reSpell[$count]=$newSpell
fi
   count=$((count+1))
   echo ""

done


printf "MISPELLED %20s\n" CORRECTIONS
echo ""
for (( i=0; i<${#uncorrect[*]}; i++));  do
printf "${uncorrect[$i]} %-20s%s\n" ${reSpell[$i]}

done

 

2 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

redirecting the output of aspell

Hi, I have 2 identical servers both running aspell but for some reason I can't redirect the output to a file on one of them. This is what I'm trying to do: echo feck | aspell -l > errors.txt On one machine this works fine but the other it doesn't (the file is created but it is empty). ... (6 Replies)
Discussion started by: leekb
6 Replies

2. UNIX for Dummies Questions & Answers

Trouble getting aspell to work

Hi: I've tried to get aspell to work to check a latex document I have. I get this error message: Error: No word lists can be found for the language "en_CA". Can anyone offer any suggestions? I'm trying to get a good spell-checker set up for my latex documents. Excalibur does not work all... (1 Reply)
Discussion started by: spindoctor
1 Replies
COUNT(3)								 1								  COUNT(3)

count - Count all elements in an array, or something in an object

SYNOPSIS
int count (mixed $array_or_countable, [int $mode = COUNT_NORMAL]) DESCRIPTION
Counts all elements in an array, or something in an object. For objects, if you have SPL installed, you can hook into count(3) by implementing interface Countable. The interface has exactly one method, Countable::count, which returns the return value for the count(3) function. Please see the Array section of the manual for a detailed explanation of how arrays are implemented and used in PHP. PARAMETERS
o $array_or_countable - An array or Countable object. o $mode - If the optional $mode parameter is set to COUNT_RECURSIVE (or 1), count(3) will recursively count the array. This is particu- larly useful for counting all the elements of a multidimensional array. Caution count(3) can detect recursion to avoid an infinite loop, but will emit an E_WARNING every time it does (in case the array contains itself more than once) and return a count higher than may be expected. RETURN VALUES
Returns the number of elements in $array_or_countable. If the parameter is not an array or not an object with implemented Countable inter- face, 1 will be returned. There is one exception, if $array_or_countable is NULL, 0 will be returned. Caution count(3) may return 0 for a variable that isn't set, but it may also return 0 for a variable that has been initialized with an empty array. Use isset(3) to test if a variable is set. EXAMPLES
Example #1 count(3) example <?php $a[0] = 1; $a[1] = 3; $a[2] = 5; $result = count($a); // $result == 3 $b[0] = 7; $b[5] = 9; $b[10] = 11; $result = count($b); // $result == 3 $result = count(null); // $result == 0 $result = count(false); // $result == 1 ?> Example #2 Recursive count(3) example <?php $food = array('fruits' => array('orange', 'banana', 'apple'), 'veggie' => array('carrot', 'collard', 'pea')); // recursive count echo count($food, COUNT_RECURSIVE); // output 8 // normal count echo count($food); // output 2 ?> SEE ALSO
is_array(3), isset(3), strlen(3). PHP Documentation Group COUNT(3)
All times are GMT -4. The time now is 01:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy