"Fossies" - the Fresh Open Source Software Archive

Member "aspell-0.60.8/test/suggest/run-batch" (8 Oct 2019, 1333 Bytes) of package /linux/misc/aspell-0.60.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/perl
    2 
    3 use strict;
    4 use warnings;
    5 use autodie;
    6 no warnings 'uninitialized';
    7 
    8 use IPC::Open2;
    9 use IO::Handle;
   10 use POSIX qw(clock CLOCKS_PER_SEC);
   11 
   12 my $in = new IO::Handle;
   13 my $out = new IO::Handle;
   14 my $data = new IO::Handle;
   15 
   16 die "Usage: $0 <command> <input> <output-base>\n" unless @ARGV == 3;
   17 
   18 my $command = $ARGV[0];
   19 my $base = $ARGV[2];
   20 
   21 open $data, $ARGV[1];
   22 
   23 open R, ">$base.res";
   24 
   25 my $pid = open2($in, $out, "$command -d en_US-w_repl --dont-use-other-dicts --per-conf=/dev/null -a");
   26 print $out "!\n";
   27 <$in>;
   28 
   29 while (<$data>) {
   30   chop;
   31   my ($mis, $cor) = split /\t/;
   32   die ":$mis:  :$cor:" if $mis !~ /^[a-zA-Z\']+ ?[a-zA-Z\']+$/;
   33   die ":$mis:  :$cor:" if $cor !~ /^[a-zA-Z\']+ ?[a-zA-Z\']+$/;
   34   print $out "$cor\n";
   35   my $res = <$in>;
   36   chop $res;
   37   if ($res) {
   38     print R "$mis\t$cor\t-1\t-1\n";
   39     $res = <$in>;
   40   } else {
   41     print $out "$mis\n";
   42     $res = <$in>;
   43     chop $res;
   44     if (!$res) {
   45       print R "$mis\t$cor\t-1\t-1\n";
   46     } else {
   47       my ($info, $list) = split /: /, $res;
   48       my ($key, undef, $num, undef) = split / /, $info;
   49       my @list = split /, /, $list;
   50       my $i;
   51       for ($i = 0; $list[$i] && $list[$i] ne $cor; $i++) {}
   52       if ($list[$i]) {$i++}
   53       else {$i = 0;}
   54       print R "$mis\t$cor\t$i\t$num\t$list\n";
   55       $res = <$in>;
   56     }
   57   }
   58 }
   59 
   60 close $out;
   61 close R;
   62 
   63 
   64