2010-10-11 15:32:27 +04:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
use strict;
|
2013-01-14 23:22:29 +04:00
|
|
|
use FindBin qw($RealBin);
|
2010-10-11 15:32:27 +04:00
|
|
|
|
|
|
|
use Getopt::Long "GetOptions";
|
|
|
|
my ($IN,$OUT,$MXPOST);
|
|
|
|
if (!&GetOptions('mxpost=s' => \$MXPOST) ||
|
|
|
|
!($IN = shift @ARGV) ||
|
|
|
|
!($OUT = shift @ARGV) ||
|
|
|
|
!defined($MXPOST)) {
|
|
|
|
print "syntax: make-pos-en.mxpost.perl -mxpost INSTALL_DIR IN_FILE OUT_FILE\n";
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2010-10-21 13:49:27 +04:00
|
|
|
my $pipeline = "perl -ne 'chop; tr/\\x20-\\x7f/\?/c; print \$_.\"\\n\";' | tee debug | ";
|
|
|
|
$pipeline .= "$MXPOST/mxpost $MXPOST/tagger.project |";
|
2013-01-14 23:22:29 +04:00
|
|
|
open(TAGGER,"$RealBin/../../tokenizer/deescape-special-chars.perl < $IN | $pipeline");
|
|
|
|
open(OUT,"| $RealBin/../../tokenizer/escape-special-chars.perl > $OUT");
|
2010-10-11 15:32:27 +04:00
|
|
|
while(<TAGGER>) {
|
|
|
|
foreach my $word_pos (split) {
|
|
|
|
$word_pos =~ s/\/([^\/]+)$/_$1/;
|
|
|
|
$word_pos = "//_:" if $word_pos eq "//";
|
|
|
|
print STDERR "faulty POS tag: $word_pos\n"
|
|
|
|
unless $word_pos =~ /^.+_([^_]+)$/;
|
|
|
|
print OUT "$1 ";
|
|
|
|
}
|
|
|
|
print OUT "\n";
|
|
|
|
}
|
|
|
|
close(OUT);
|
|
|
|
close(TAGGER);
|
|
|
|
|