The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl
#-*-perl-*-
#
# USAGE: alpino2tiger [-i]
#
#  -i .... skip indexed
#

use strict;
use FindBin;
use lib $FindBin::Bin.'/../lib';
use Lingua::Align::Corpus;

use vars qw($opt_i);
use Getopt::Std;
getopts('i');

my $infile = $ARGV[0];
my $outfile = $ARGV[1];


my $corpus = new Lingua::Align::Corpus(-file => $infile,
				       -type => 'AlpinoXML',
				       -skip_indexed => $opt_i);

my $output = new Lingua::Align::Corpus(-type => 'TigerXML');


open F,">$outfile.tmp" || die "cannot open $outfile.tmp\n";
binmode(F, ":utf8");

my %sent=();
while ($corpus->next_sentence(\%sent)){
#    print $output->print_tree(\%sent);
    print F $output->print_tree(\%sent);
#    print $sent{ID},"\n";
}

close F;

open F,">$outfile" || die "cannot open $outfile\n";
binmode(F, ":utf8");

print F $output->print_header();
close F;

system "cat $outfile.tmp >> $outfile";
system "rm -f $outfile.tmp";

open F,">>$outfile" || die "cannot open $outfile\n";
binmode(F, ":utf8");
print F $output->print_tail();
close F;