Add KorAP-XML-CoNLL-U plugin
Change-Id: I45b2d5132790958efde209d0f93fe830912abb0d
diff --git a/Changes b/Changes
index abef1c7..c0fab50 100755
--- a/Changes
+++ b/Changes
@@ -1,4 +1,8 @@
-0.48 2023-02-02
+0.49 2023-02-14
+ - Introduce conllu2korapxml command via plugin. (diewald)
+ - Introduce korapxml2conllu command via plugin. (diewald)
+
+0.48 2023-01-12
- Added support for NKJP tagset in annotation
assistant. (diewald)
- Remove deprecated 'auth_support' (since 0.31)
diff --git a/Dockerfile b/Dockerfile
index 21d77de..7c53ea0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -102,6 +102,7 @@
RUN cpanm \
https://github.com/KorAP/KorAP-XML-TEI/archive/refs/tags/v2.4.1.tar.gz \
https://github.com/KorAP/KorAP-XML-Krill/archive/refs/tags/v0.49.tar.gz
+ https://github.com/KorAP/KorAP-XML-CoNLL-U/archive/refs/tags/v0.6.0.tar.gz
# Remove all build dependencies
RUN apk del git \
@@ -129,7 +130,7 @@
ENV MOJO_LISTEN http://*:${MOJO_PORT}
ENV MOJO_MODE production
-RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML']}}" > kalamar.production.conf
+RUN echo "{Kalamar=>{plugins=>['KorAPXML2Krill','Tei2KorAPXML','KorAPXML2CoNNLU']}}" > kalamar.production.conf
EXPOSE ${MOJO_PORT}
diff --git a/README.md b/README.md
index 01be02c..768a951 100644
--- a/README.md
+++ b/README.md
@@ -247,7 +247,7 @@
- `KorAPXML2Krill`: For integrated calls to [korapxml2krill](https://github.com/KorAP/KorAP-XML-Krill), if installed.
- `KrillIndexer`: For integrated calls to [Krilll](https://github.com/KorAP/Krill),
if installed and exposed by `KRILL_INDEXER_PATH`.
-
+- `KorAPXML2CoNLLU`: For integrated calls to [conllu2korapxml and korapxml2conllu](https://github.com/KorAP/KorAP-XML-CoNNL-U), if installed.
## Troubleshooting
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 5da9493..c36c8a2 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -8,7 +8,7 @@
use List::Util qw!none uniq!;
# Minor version - may be patched from package.json
-our $VERSION = '0.48';
+our $VERSION = '0.49';
# Supported version of Backend API
our $API_VERSION = '1.0';
diff --git a/lib/Kalamar/Plugin/KorAPXML2CoNLLU.pm b/lib/Kalamar/Plugin/KorAPXML2CoNLLU.pm
new file mode 100644
index 0000000..d8cfae0
--- /dev/null
+++ b/lib/Kalamar/Plugin/KorAPXML2CoNLLU.pm
@@ -0,0 +1,14 @@
+package Kalamar::Plugin::KorAPXML2CoNLLU;
+use Mojo::Base 'Mojolicious::Plugin';
+use Mojo::Base -strict;
+sub register {
+ my ($plugin, $mojo) = @_;
+ my $script = `sh -c 'command -v conllu2korapxml'`;
+ if ($script ne '') {
+ # Add additional command path
+ push(@{$mojo->commands->namespaces}, __PACKAGE__);
+ return 1;
+ };
+ return 0;
+};
+1;
diff --git a/lib/Kalamar/Plugin/KorAPXML2CoNLLU/conllu2korapxml.pm b/lib/Kalamar/Plugin/KorAPXML2CoNLLU/conllu2korapxml.pm
new file mode 100644
index 0000000..f6eb0c3
--- /dev/null
+++ b/lib/Kalamar/Plugin/KorAPXML2CoNLLU/conllu2korapxml.pm
@@ -0,0 +1,15 @@
+package Kalamar::Plugin::KorAPXML2CoNLLU::conllu2korapxml;
+use Mojo::Base 'Mojolicious::Command';
+
+has description => 'Conversion of KorAP-XML CoNLL-U to KorAP-XML zips';
+has usage => sub {
+ return qx{conllu2korapxml --help};
+};
+
+sub run {
+ shift;
+ system('conllu2korapxml', @_);
+ return 1;
+};
+
+1;
diff --git a/lib/Kalamar/Plugin/KorAPXML2CoNLLU/korapxml2conllu.pm b/lib/Kalamar/Plugin/KorAPXML2CoNLLU/korapxml2conllu.pm
new file mode 100644
index 0000000..2ba8d63
--- /dev/null
+++ b/lib/Kalamar/Plugin/KorAPXML2CoNLLU/korapxml2conllu.pm
@@ -0,0 +1,15 @@
+package Kalamar::Plugin::KorAPXML2CoNLLU::korapxml2conllu;
+use Mojo::Base 'Mojolicious::Command';
+
+has description => 'Conversion of KorAP-XML zips to CoNLL-U';
+has usage => sub {
+ return qx{korapxml2conllu --help};
+};
+
+sub run {
+ shift;
+ system('korapxml2conllu', @_);
+ return 1;
+};
+
+1;
diff --git a/package.json b/package.json
index 8f545f0..7aa0d03 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "Kalamar",
"description": "Mojolicious-based Frontend for KorAP",
"license": "BSD-2-Clause",
- "version": "0.48.1",
+ "version": "0.49.0",
"pluginVersion": "0.2.2",
"engines": {
"node": ">=6.0.0"
diff --git a/t/plugin/conllu2korapxml.t b/t/plugin/conllu2korapxml.t
new file mode 100644
index 0000000..af3d408
--- /dev/null
+++ b/t/plugin/conllu2korapxml.t
@@ -0,0 +1,33 @@
+use Test::More;
+use Test::Mojo;
+use Test::Output;
+
+my $script = `sh -c 'command -v conllu2korapxml'`;
+
+if ($script eq '') {
+ plan skip_all => "KorAP::XML::Krill is not installed";
+ exit;
+};
+
+my $t = Test::Mojo->new(Kalamar => {
+ Kalamar => {
+ plugins => ['KorAPXML2CoNLLU']
+ }
+});
+my $app = $t->app;
+my $cmds = $app->commands;
+ok(grep/::KorAPXML2CoNLLU/, @{$cmds->namespaces}, 'Namespace is set');
+stdout_like(
+ sub {
+ $cmds->run('conllu2korapxml','-v');
+ },
+ qr{zca15\.tree_tagger\.conllu}
+);
+stdout_like(
+ sub {
+ $cmds->run('korapxml2conllu','-v');
+ },
+ qr{zca15\.tree_tagger\.zip}
+);
+done_testing;
+1;