mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 14:05:29 +03:00
28 lines
586 B
Perl
Executable File
28 lines
586 B
Perl
Executable File
#!/usr/bin/perl -w
|
|
|
|
use strict;
|
|
|
|
while(<STDIN>) {
|
|
chop;
|
|
|
|
# avoid general madness
|
|
s/[\000-\037]//g;
|
|
s/\s+/ /g;
|
|
s/^ //g;
|
|
s/ $//g;
|
|
|
|
# special characters in moses
|
|
s/\&/\&/g; # escape escape
|
|
s/\|/\|/g; # factor separator
|
|
s/\</\</g; # xml
|
|
s/\>/\>/g; # xml
|
|
s/\'/\'/g; # xml
|
|
s/\"/\"/g; # xml
|
|
s/\[/\[/g; # syntax non-terminal
|
|
s/\]/\]/g; # syntax non-terminal
|
|
|
|
# restore xml instructions
|
|
s/\<(\S+) translation="(.+?)"> (.+?) <\/(\S+)>/\<$1 translation=\"$2\"> $3 <\/$4>/g;
|
|
print $_."\n";
|
|
}
|