OPUS-MT-train/scripts/fit-data-size.pl

29 lines
478 B
Perl
Raw Normal View History

#!/usr/bin/env perl
#
# simple script for filling/clipping data to a certain size
# in number of lines
use strict;
2020-06-08 14:14:55 +03:00
use Getopt::Std;
use vars qw/$opt_m/;
getopts('m:');
my $size = shift(@ARGV);
my $file = shift(@ARGV);
my $count=0;
2020-06-08 14:14:55 +03:00
my $repeated=0;
while ($count < $size){
open F,"<$file" || die "cannot read from $file!\n";
while (<F>){
$count++;
print;
last if ($count >= $size);
}
2020-06-08 14:14:55 +03:00
close F;
$repeated++;
last if ($opt_m && $repeated > $opt_m);
}