compare two text files and list of misspellings in words

December 9, 2011 at 06:13:05
Specs: Windows XP
How to make list of misspellings in the output text based on original text? batch file is requested.

See More: compare two text files and list of misspellings in words

Report •

#1
December 22, 2011 at 22:26:45
Experts,
In case if the batch file cannot created - Is it possible to create in python or perl program by EXPERTS? Awaiting valuable program early.
requirement: compare two text files and generate list of mispelling/mistakes either word or chars in the output file.

Report •

#2
December 25, 2011 at 14:42:33
This perl program reads the dictiontionary.txt file into an array. If a word in the words.txt file doesn't exist in the dictionary.txt file, it is considered misspelled. I am using the Tie::File perl module which treats a text file like an array:

#!/usr/bin/perl

use strict;
use warnings;
use Tie::File;

my @dictionary_array = ();
my $dfile='dictionary.txt';
my $infile = 'words.txt';
my $outfile='misspelled.txt';

tie @dictionary_array, 'Tie::File', $dfile or die "Cannot open $dfile: !$\n";

open(IN, '<', $infile) or die "Could not open file $infile: $! +";
open(OUT, '>', $outfile) or die "Could not open file $outfile: $! +";

while ( my $myline = <IN> )
   {
   chomp $myline;
   my $is_not_there = grep $_ eq $myline, @dictionary_array;
   if(!$is_not_there)
       {
       print OUT "$myline\n";
       }
   }

untie @dictionary_array;            # finished
close IN;
close OUT;


Report •

#3
December 26, 2011 at 02:12:28
tested works fine. I expect only list of difference of misspelling as follows:

dfile:Dictionary.txt

dictiontionary.txt file into an array. If a word in the words.txt file doesn't exist /missing in the dictionary.txt file, it is considered misspelled. I am using the Tie::File perl

Inputfile:(word.txt)

dictiiontionary.txt file info an array. If a word in the words.txt file doesn't exist /missing in the dictionary.txt file, it is considered misspelled. I ? using the Tie::File perl


Outputfile:Difference.txt
dictiiontionary.txt file info an array. If a word in the words.txt file doesn't exist / missing in the dictionary.txt file, it is considered misspelled. I am using the Tie::File perl

Difference.txt should displayed as follow:

dictiiontionary info am

I shall be thankful to you if the program is modified suitably to display only list of misspelling as example indicated above under "Difference.txt should displayed as follow"


Report •

Related Solutions

#4
December 27, 2011 at 09:50:08
First, to change your output file name, simply:

my $outfile='Difference.txt';

Second, to display all misspelled words on one line with a space between them, replace the newline, \n, with a space:

print OUT "$myline ";


Report •

#5
December 27, 2011 at 22:21:00
Difference.txt = should be displayed as follow:
[dictiiontionary info am]
whereas actual output was "dictiiontionary.txt file info an array. If a word in the words.txt file doesn't exist in the dictionary.txt file, it is considered misspelled. I "
Where I made a mistake?

modified as suggested below=
#!/usr/bin/perl

use strict;
use warnings;
use Tie::File;

my @dictionary_array = ();
my $dfile='dictionary.txt';
my $infile = 'words.txt';
my $outfile='Difference.txt';

tie @dictionary_array, 'Tie::File', $dfile or die "Cannot open $dfile: !$\n";

open(IN, '<', $infile) or die "Could not open file $infile: $! +";
open(OUT, '>', $outfile) or die "Could not open file $outfile: $! +";

while ( my $myline = <IN> )
{
chomp $myline;
my $is_not_there = grep $_ eq $myline, @dictionary_array;
if(!$is_not_there)
{
print OUT "$myline ";
}
}


Report •

Ask Question