blob: aa7993df2f1ffcfed1bb0dcc9a6b98faf812c9b1 [file] [log] [blame]
Akron405f0c52016-07-07 17:56:16 +02001#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More;
5use File::Basename 'dirname';
6use File::Spec::Functions 'catdir';
7use File::Temp qw/ :POSIX /;
8use Mojo::Util qw/slurp/;
9use Mojo::JSON qw/decode_json/;
10
11use_ok('KorAP::XML::Batch::File');
12
13ok(my $bf = KorAP::XML::Batch::File->new(
14 overwrite => 1,
15 foundry => 'OpenNLP',
16 layer => 'Tokens'
17), 'Construct new batch file object');
18
19# gzip => 1,
20
21my $path = catdir(dirname(__FILE__), 'annotation', 'corpus', 'doc', '0001');
22
23my $output = tmpnam();
24ok($bf->process($path => $output), 'Process file');
25
26ok(-f $output, 'File exists');
27
28ok(my $file = slurp $output, 'Slurp data');
29
30ok(my $json = decode_json $file, 'decode json');
31
32is($json->{textType}, 'Zeitung: Tageszeitung', 'text type');
33is($json->{title}, 'Beispiel Text', 'Title');
34is($json->{data}->{tokenSource}, 'opennlp#tokens', 'Title');
35is($json->{data}->{foundries}, '', 'Foundries');
36like($json->{data}->{text}, qr/^Zum letzten kulturellen/, 'Foundries');
37is($json->{data}->{stream}->[0]->[0], '-:tokens$<i>18', 'Tokens');
38is($json->{data}->{stream}->[0]->[1], '<>:base/s:t$<b>64<i>0<i>129<i>17<b>0', 'Data');
39
40done_testing;
41__END__