How to make list of misspellings in the output text based on original text? batch file is requested.
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.
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;
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 perlDifference.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"
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 ";
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/perluse 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 ";
}
}
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |