#!/usr/bin/perl
#
# -*-perl-*-
#
# Copyright (C) 2004 Jrg Tiedemann  <joerg@stp.ling.uu.se>
#
# $Id: giza2links,v 1.1.1.1 2004/05/03 15:39:55 joerg72 Exp $
#----------------------------------------------------------------------------
#
# 

use strict;

#---------------------------------------------------------------------------

while (<>){

    $_=<>;                 # target sentence (without links)
    chomp;
    my @trg=split(/ /);
    $_=<>;                 # source sentence (with links)
    chomp;

    my %align=();

    while (/(\S.*?)\s\(\{\s(.*?)\}\)/g){
	printf "%25s\t",$1;
	my @links=split(/\s/,$2);
	if (not @links){print ' NULL';}
	foreach (@links){print ' ',$trg[$_-1];}
	print "\n";
    }
}
