mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-19 23:27:46 +03:00
ef028446f3
This is not pleasant to read (and much, much less pleasant to write!) but sort of necessary in an open project. Right now it's quite hard to figure out what is licensed how, which doesn't matter much to most people but can suddenly become very important when people want to know what they're being allowed to do. I kept the notices as short as I could. As far as I could see, everything without a clear license notice is LGPL v2.1 or later.
43 lines
1.1 KiB
Perl
Executable File
43 lines
1.1 KiB
Perl
Executable File
#!/usr/bin/env perl
|
|
#
|
|
# This file is part of moses. Its use is licensed under the GNU Lesser General
|
|
# Public License version 2.1 or, at your option, any later version.
|
|
|
|
use warnings;
|
|
use strict;
|
|
|
|
# Create domain file from corpora
|
|
# (helper for domain adatpation)
|
|
|
|
# Creates a file with domain names and end line numbers for different domains
|
|
# within the cleaned training corpus. This file is used by various domain
|
|
# adaptation methods.
|
|
|
|
my ($extension,@SUBCORPORA) = @ARGV;
|
|
|
|
my $line_count = 0;
|
|
my %UNIQUE_NAME;
|
|
my $number = 1;
|
|
foreach (@SUBCORPORA) {
|
|
# get number of lines
|
|
if (!-e "$_.$extension" && -e "$_.$extension.gz") {
|
|
$line_count += `zcat $_.$extension.gz | wc -l`;
|
|
}
|
|
elsif (-e "$_.$extension") {
|
|
$line_count += `wc -l < $_.$extension`;
|
|
}
|
|
else {
|
|
die("ERROR: could not open sub corpus file $_.$extension\n");
|
|
}
|
|
|
|
# construct name
|
|
my $name = $number++; # default: cardinal number
|
|
while(defined($UNIQUE_NAME{$name})) { $name = $number++; } # slightly paranoid
|
|
if (/\/([^\.\/]+)\.[^\/]+$/ && !defined($UNIQUE_NAME{$1})) { # reconstruct corpus name
|
|
$name = $1;
|
|
$UNIQUE_NAME{$1}++;
|
|
}
|
|
print "$line_count $name\n";
|
|
}
|
|
|