File: run-batch

package info (click to toggle)
aspell 0.60.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,336 kB
  • sloc: cpp: 24,378; sh: 12,340; perl: 1,924; ansic: 1,661; makefile: 852; sed: 16
file content (64 lines) | stat: -rwxr-xr-x 1,333 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/perl

use strict;
use warnings;
use autodie;
no warnings 'uninitialized';

use IPC::Open2;
use IO::Handle;
use POSIX qw(clock CLOCKS_PER_SEC);

my $in = new IO::Handle;
my $out = new IO::Handle;
my $data = new IO::Handle;

die "Usage: $0 <command> <input> <output-base>\n" unless @ARGV == 3;

my $command = $ARGV[0];
my $base = $ARGV[2];

open $data, $ARGV[1];

open R, ">$base.res";

my $pid = open2($in, $out, "$command -d en_US-w_repl --dont-use-other-dicts --per-conf=/dev/null -a");
print $out "!\n";
<$in>;

while (<$data>) {
  chop;
  my ($mis, $cor) = split /\t/;
  die ":$mis:  :$cor:" if $mis !~ /^[a-zA-Z\']+ ?[a-zA-Z\']+$/;
  die ":$mis:  :$cor:" if $cor !~ /^[a-zA-Z\']+ ?[a-zA-Z\']+$/;
  print $out "$cor\n";
  my $res = <$in>;
  chop $res;
  if ($res) {
    print R "$mis\t$cor\t-1\t-1\n";
    $res = <$in>;
  } else {
    print $out "$mis\n";
    $res = <$in>;
    chop $res;
    if (!$res) {
      print R "$mis\t$cor\t-1\t-1\n";
    } else {
      my ($info, $list) = split /: /, $res;
      my ($key, undef, $num, undef) = split / /, $info;
      my @list = split /, /, $list;
      my $i;
      for ($i = 0; $list[$i] && $list[$i] ne $cor; $i++) {}
      if ($list[$i]) {$i++}
      else {$i = 0;}
      print R "$mis\t$cor\t$i\t$num\t$list\n";
      $res = <$in>;
    }
  }
}

close $out;
close R;