Welcome to mirror list, hosted at ThFree Co, Russian Federation.

make-factor-de-morph.perl « wrappers « training « scripts - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1cc917bcef007217d0f5faab804f72ed11e58141 (plain)
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
#!/usr/bin/env perl 

use warnings;
use strict;
use Encode;
use FindBin qw($RealBin);
my ($in,$out,$tmpdir) = @ARGV;

`mkdir -p $tmpdir`;
`$RealBin/../../tokenizer/deescape-special-chars.perl < $in | /home/pkoehn/statmt/bin/unicode2latin1.perl > $tmpdir/tok.$$`;
`/home/pkoehn/statmt/bin/run-lopar-tagger.perl $tmpdir/tok.$$ $tmpdir/lopar.$$`;

open(LOPAR,"$tmpdir/lopar.$$");
open(OUT,"|$RealBin/../../tokenizer/escape-special-chars.perl >$out");
while(<LOPAR>) {
    chomp;
    s/ +/ /g;
    s/^ //;
    s/ $//;
    my $first = 1;
    foreach (split) {
        die("ERROR: choked on token '$_'") unless /^(.+)_([^_]+)_(.+)$/;
        my ($word,$morph,$lemma) = ($1,$2,$3);
	print OUT " " unless $first;
	$first = 0;
	print OUT encode('utf8', decode('iso-8859-1', $morph));
    }
    print OUT "\n";
}
close(LOPAR);
close(OUT);