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

input-from-sgm.perl « support « ems « scripts - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 223996676f17886a34d34756b8cb9aee0469c351 (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
#!/usr/bin/env perl 

use warnings;
use strict;

die("ERROR syntax: input-from-sgm.perl < in.sgm > in.txt") 
    unless scalar @ARGV == 0;

while(my $line = <STDIN>) {
    chop($line);
    while ($line =~ /<seg[^>]+>\s*$/i) {
	my $next_line = <STDIN>;
	$line .= $next_line;
	chop($line);
    }
    while ($line =~ /<seg[^>]+>\s*(.*)\s*$/i &&
	   $line !~ /<seg[^>]+>\s*(.*)\s*<\/seg>/i) {
	my $next_line = <STDIN>;
	$line .= $next_line;
	chop($line);	
    }
    if ($line =~ /<seg[^>]+>\s*(.*)\s*<\/seg>/i) {
	my $input = $1;
	$input =~ s/\s+/ /g;
	$input =~ s/^ //g;
	$input =~ s/ $//g;
	print $input."\n";
    }
}