I_pron
would_mod
like_v
to_to
learn_v
this_pron
._sent
OK_ok
?_quest
####
I would like to learn this .
OK ?
####
$DOC1="1.txt";
$DOC2="2.txt";
# Create an associative lookup array from file 1
open (DOC1,$DOC1);
while () {
chomp($_);
$ind = (split /_/)[0];
$lookup{$ind} = $_;
}
close (DOC1);
open (DOC2,$DOC2);
@lines=;
close (DOC2);
$outln = '';
foreach $line (@lines) {
@words = split(/ /, $line);
foreach $word (@words) {
chomp($word); # Get rid of stray carriage return
$outln = $outln . " " . $lookup{$word};
}
}
print "$outln\n";