mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 21:42:19 +03:00
ef028446f3
This is not pleasant to read (and much, much less pleasant to write!) but sort of necessary in an open project. Right now it's quite hard to figure out what is licensed how, which doesn't matter much to most people but can suddenly become very important when people want to know what they're being allowed to do. I kept the notices as short as I could. As far as I could see, everything without a clear license notice is LGPL v2.1 or later.
49 lines
911 B
Perl
Executable File
49 lines
911 B
Perl
Executable File
#!/usr/bin/env perl
|
|
#
|
|
# This file is part of moses. Its use is licensed under the GNU Lesser General
|
|
# Public License version 2.1 or, at your option, any later version.
|
|
|
|
use warnings;
|
|
use strict;
|
|
|
|
while (my $line = <STDIN>) {
|
|
chomp($line);
|
|
#print "$line\n";
|
|
|
|
my $len = length($line);
|
|
my $inXML = 0;
|
|
my $prevSpace = 1;
|
|
my $prevBar = 0;
|
|
|
|
for (my $i = 0; $i < $len; ++$i) {
|
|
my $c = substr($line, $i, 1);
|
|
if ($c eq "<" && !$prevBar) {
|
|
++$inXML;
|
|
}
|
|
elsif ($c eq ">" && $inXML>0) {
|
|
--$inXML;
|
|
}
|
|
elsif ($prevSpace == 1 && $c eq " ")
|
|
{ # duplicate space. Do nothing
|
|
}
|
|
elsif ($inXML == 0) {
|
|
if ($c eq " ") {
|
|
$prevSpace = 1;
|
|
$prevBar = 0;
|
|
}
|
|
elsif ($c eq "|") {
|
|
$prevSpace = 0;
|
|
$prevBar = 1;
|
|
}
|
|
else {
|
|
$prevSpace = 0;
|
|
$prevBar = 0;
|
|
}
|
|
print $c;
|
|
}
|
|
}
|
|
|
|
print "\n";
|
|
}
|
|
|