Minor cleanups of main script
Change-Id: I174416a84d26ec85b443b071cf8457ad7c689377
diff --git a/script/korapxml2krill b/script/korapxml2krill
index cb1863c..a6074f6 100644
--- a/script/korapxml2krill
+++ b/script/korapxml2krill
@@ -221,6 +221,13 @@
}
);
+my %ERROR_HASH = (
+ -sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS',
+ -verbose => 99,
+ -msg => $VERSION_MSG,
+ -output => '-',
+ -exit => 1
+);
# Load from configuration and fill non-given data
if ($cfg_file && -e $cfg_file) {
@@ -299,14 +306,6 @@
exit 1;
};
-my %ERROR_HASH = (
- -sections => 'NAME|SYNOPSIS|ARGUMENTS|OPTIONS',
- -verbose => 99,
- -msg => $VERSION_MSG,
- -output => '-',
- -exit => 1
-);
-
# Input has to be defined
pod2usage(%ERROR_HASH) unless @input;
@@ -314,22 +313,9 @@
pod2usage(%ERROR_HASH) if $gzip && !$output;
-# Auto adjust jobs
-if ($jobs eq '-1') {
- my $cores = Sys::Info->new->device('CPU')->count;
- $jobs = ceil(5 * $cores);
- $log->info("Run using $jobs jobs on $cores cores");
-};
-
-
# Start serial processing
if ($cmd && $cmd eq 'serial') {
- if ($output && (!defined($to_tar)) && (!-e $output || !-d $output)) {
- $log->error("Directory '$output' does not exist.");
- exit 1;
- };
-
# Remove all inputs
my $remove_next = 0;
@keep_argv = @{c(@keep_argv)->grep(
@@ -377,6 +363,7 @@
exit;
};
+
my @layers;
push(@layers, ['Base', 'Sentences']) unless $base_sentences;
push(@layers, ['Base', 'Paragraphs']) unless $base_paragraphs;
@@ -520,8 +507,17 @@
non_verbal_tokens => ($cfg{non_verbal_tokens} // 0)
);
+
+# Auto adjust jobs
+if ($jobs eq '-1') {
+ my $cores = Sys::Info->new->device('CPU')->count;
+ $jobs = ceil(5 * $cores);
+ $log->info("Run using $jobs jobs on $cores cores");
+};
+
+
# Glob and prefix files
-if (@input) {
+if (@input > 0) {
my @new_input = ();
@@ -561,7 +557,7 @@
};
# Create and parse new document
- $input =~ s{([^/])$}{$1/};
+ $input =~ s{([^/])$}{$1/}o;
# Process file
$batch_file->process($input, $output);
@@ -860,7 +856,6 @@
$filename
]
);
- #$pool->finish(0, ["Processed " . $filename, $temp]);
}
else {
# Delete temporary file