mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
script to convert arabic to bw, and vice versa
This commit is contained in:
parent
8adad4fc2e
commit
b7792b227a
33
scripts/other/buckwalter.perl
Executable file
33
scripts/other/buckwalter.perl
Executable file
@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Encode::Arabic::Buckwalter;
|
||||
use Getopt::Long "GetOptions";
|
||||
|
||||
my $direction;
|
||||
GetOptions('direction=i' => \$direction)
|
||||
or exit(1);
|
||||
# direction: 1=arabic->bw, 2=bw->arabic
|
||||
|
||||
die("ERROR: need to set direction") unless defined($direction);
|
||||
|
||||
|
||||
|
||||
while (my $line = <STDIN>) {
|
||||
chomp($line);
|
||||
|
||||
my $lineOut;
|
||||
if ($direction == 1) {
|
||||
$lineOut = encode 'buckwalter', decode 'utf8', $line;
|
||||
}
|
||||
elsif ($direction == 2) {
|
||||
$lineOut = encode 'utf8', decode 'buckwalter', $line;
|
||||
}
|
||||
else {
|
||||
die("Unknown direction: $direction");
|
||||
}
|
||||
print "$lineOut\n";
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user