summaryrefslogtreecommitdiff
path: root/compound-split/compound-split.pl
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-02-16 00:13:17 +0100
committerPatrick Simianer <p@simianer.de>2014-02-16 00:13:17 +0100
commitab71c44e61d00c788e84b44156d0be16191e267d (patch)
tree27d1c7e74e8b07276312766a5908853465a3ed18 /compound-split/compound-split.pl
parent4494c2cae3bed81f9d2d24d749e99bf66a734bc5 (diff)
parent9e2f7fcfa76213f5e41abb4f4c9a264ebe8f9d8c (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'compound-split/compound-split.pl')
-rwxr-xr-xcompound-split/compound-split.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/compound-split/compound-split.pl b/compound-split/compound-split.pl
index 62259146..93ac3b20 100755
--- a/compound-split/compound-split.pl
+++ b/compound-split/compound-split.pl
@@ -35,6 +35,7 @@ die "Don't know about language: $LANG\n" unless -d "./$LANG";
my $CONFIG="cdec-$LANG.ini";
die "Can't find $CONFIG" unless -f $CONFIG;
die "--output must be '1best' or 'plf'\n" unless ($OUTPUT =~ /^(plf|1best)$/);
+check_dependencies($CONFIG, $LANG);
print STDERR "(Run with --help for options)\n";
print STDERR "LANGUAGE: $LANG\n";
print STDERR " OUTPUT: $OUTPUT\n";
@@ -146,3 +147,31 @@ Usage: $0 [OPTIONS] < file.txt
EOT
exit(1);
}
+
+sub check_dependencies {
+ my ($conf, $lang) = @_;
+ my @files = ();
+ open F, "<$conf" or die "Can't read $conf: $!";
+ while(<F>){
+ chomp;
+ my @x = split /\s+/;
+ for my $f (@x) {
+ push @files, $f if ($f =~ /\.gz$/);
+ }
+ }
+ close F;
+ my $c = 0;
+ for my $file (@files) {
+ $c++ if -f $file;
+ }
+ if ($c != scalar @files) {
+ print STDERR <<EOT;
+Missing data dependencies; to install, please run:
+
+ $script_dir/install-data-deps.sh
+
+EOT
+ exit(1);
+ }
+}
+