Check version of KorAP-Tokenizer when requested
Change-Id: Iea411e514ba3a3eb8eb93a252c9652f38095a98d
diff --git a/script/tei2korapxml b/script/tei2korapxml
index 63ea525..5c74b91 100755
--- a/script/tei2korapxml
+++ b/script/tei2korapxml
@@ -59,6 +59,7 @@
'header-file=s' => \(my $header_file = 'header'),
'tokens-file=s' => \(my $tokens_file = 'tokens'),
'log|l=s' => \(my $log_level = 'notice'),
+ 'required-version|rv=s' => \(my $required_version),
'' => \(my $stdio),
'help|h' => sub {
pod2usage(
@@ -84,6 +85,15 @@
$log->notice('Debugging is activated') if DEBUG;
+if ($required_version) {
+ $required_version =~ /^\s*(\d+\.\d+\.\d+)\s*$/;
+ if (!$1 || $1 ne $VERSION) {
+ $log->error("Required version $required_version mismatches version $VERSION");
+ exit(1);
+ };
+};
+
+
# tag (without attributes), which contains the primary text
my $_TEXT_BODY = 'text';
# optional
@@ -111,6 +121,13 @@
require KorAP::XML::TEI::Tokenizer::KorAP;
1;
};
+
+ my $korap_tok_ver = $KorAP::XML::TEI::Tokenizer::KorAP::VERSION;
+ if ($korap_tok_ver ne $VERSION) {
+ $log->error("KorAP-Tokenizer version ($korap_tok_ver) differs from the expected version ($VERSION)");
+ exit(1);
+ };
+
$ext_tok = KorAP::XML::TEI::Tokenizer::KorAP->new($use_tokenizer_sentence_splits);
};
@@ -514,6 +531,11 @@
Print version information.
+=item B<--required-version|-rv>
+
+Version required for conversion. If the script doesn't match
+the version passed, it will exit immediately.
+
=item B<--tokenizer-call|-tc>
Call an external tokenizer process, that will tokenize