blob: 053f80bb4c448dd4f01094a0b55aa5199696af4a [file] [log] [blame]
Akrone1dbc382016-07-08 22:24:52 +02001#/usr/bin/env perl
2use strict;
3use warnings;
4use File::Basename 'dirname';
5use File::Spec::Functions qw/catdir catfile/;
6use File::Temp qw/ :POSIX /;
7use Mojo::Util qw/slurp/;
8use Mojo::JSON qw/decode_json/;
9use IO::Uncompress::Gunzip;
10use Test::More;
11
12my $f = dirname(__FILE__);
13my $script = catfile($f, '..', '..', 'script', 'korapxml2krill');
14my $input = catdir($f, '..', 'annotation', 'corpus', 'doc', '0001');
15my $output = tmpnam();
16
17ok(-f $script, 'Script found');
18ok(-d $input, 'Input directory found');
19
20my $call = 'perl ';
21$call .= $script . ' ';
22$call .= "--input $input ";
23$call .= "--output $output ";
24$call .= '-t OpenNLP#Tokens ';
25
26system($call);
27
28ok(my $file = slurp $output, 'Slurp data');
29ok(my $json = decode_json $file, 'decode json');
30is($json->{textType}, 'Zeitung: Tageszeitung', 'text type');
31is($json->{title}, 'Beispiel Text', 'Title');
32is($json->{data}->{tokenSource}, 'opennlp#tokens', 'Title');
33is($json->{data}->{foundries}, 'base base/paragraphs base/sentences connexor connexor/morpho connexor/phrase connexor/sentences connexor/syntax corenlp corenlp/constituency corenlp/morpho corenlp/sentences dereko dereko/structure glemm glemm/morpho mate mate/dependency mate/morpho opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences xip xip/constituency xip/morpho xip/sentences', 'Foundries');
34like($json->{data}->{text}, qr/^Zum letzten kulturellen/, 'Foundries');
35is($json->{data}->{stream}->[0]->[0], '-:base/paragraphs$<i>1', 'Paragraphs');
36
37system($call . ' -z');
38
39my $gz = IO::Uncompress::Gunzip->new($output);
40ok($gz->read($file), 'Uncompress');
41
42ok($json = decode_json $file, 'decode json');
43is($json->{textType}, 'Zeitung: Tageszeitung', 'text type');
44is($json->{title}, 'Beispiel Text', 'Title');
45is($json->{data}->{tokenSource}, 'opennlp#tokens', 'Title');
46is($json->{data}->{foundries}, 'base base/paragraphs base/sentences connexor connexor/morpho connexor/phrase connexor/sentences connexor/syntax corenlp corenlp/constituency corenlp/morpho corenlp/sentences dereko dereko/structure glemm glemm/morpho mate mate/dependency mate/morpho opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences xip xip/constituency xip/morpho xip/sentences', 'Foundries');
47like($json->{data}->{text}, qr/^Zum letzten kulturellen/, 'Foundries');
48is($json->{data}->{stream}->[0]->[0], '-:base/paragraphs$<i>1', 'Paragraphs');
49
50
51done_testing;
52__END__