Re: counting mispelled words


Subject: Re: counting mispelled words
From: Mac Mason (julian_mason@hmc.edu)
Date: Wed Jan 21 2004 - 22:41:10 AKST


So, I was bored, and wrote you a program.

It's reproduced below; copy into a file, make executable, and read the
header comment to see how to use it.

#! /usr/bin/perl

#
# Written by Mac Mason on a whim; spits out number of misspelled words.
# Uncommenting one line will allow printing of misspelled words.
# Program is pretty dumb; it requires the dictionary to have every word
# seperated by newlines.
#

use strict;

my $counter = 0;

if (@ARGV < 2)
{
    print "Need two arguments; \'./program DICTIONARY FILE_TO_CHECK\'\n"
}

my $dictfile = @ARGV[0];
my $checkfile = @ARGV[1];

open DICT, "$dictfile" or die "Can't open dictionary!";
open FILE, "$checkfile" or die "Can't open file to check!";

chomp(my @temp = <DICT>);

my %dict;

foreach (@temp)
{
    $dict{$_} = 1;
}

while (<FILE>)
{
   my @line = split;

    foreach (@line)
    {
        if (!exists $dict{$_})
        {
            $counter++;
# print "$_\n"; # Uncomment to get printout of words
        }
    }
}

print "$counter misspelled words\n";

# End of program

Have fun!

~Mac~

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.



This archive was generated by hypermail 2a23 : Thu Jan 22 2004 - 07:57:05 AKST