PERL 12
Convert-nc9.pl Guest on 21st November 2020 05:35:31 PM
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use File::Basename qw/basename/;
  5.  
  6. my $corpushome = shift(@ARGV) || 'data/News-Commentary/aligned';
  7.  
  8. my @files = `ls $corpushome/French-English/English/*.txt`;
  9.  
  10. foreach my $f (@files){
  11.     chomp $f;
  12.     open S,"<$f" || die "problems with $f";
  13.     $f=~s/\/English\//\/French\//;
  14.     open T,"<$f" || die "problems with $f";
  15.  
  16.     my @markup=();
  17.     while (<S>){
  18.         chomp;
  19.         my $trg=<T>;
  20.  
  21.         if (/^</){
  22.             push(@markup,$_);
  23.             next;
  24.         }
  25.         else{
  26.             if (($_=~/\S/) && ($trg=~/\S/)){
  27.                 print $_,' ||| ';
  28.                 print $trg;
  29.                 print STDERR basename($f),"\t";
  30.                 print STDERR join(' ',@markup);
  31.                 print STDERR "\n";
  32.                 @markup=();
  33.             }
  34.         }
  35.     }
  36. }

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.