blob: cbbbf270847bde5324115f20f2ab27d41b6dd5c6 [file] [log] [blame]
Akron194be542016-01-21 12:52:43 +01001#!/usr/bin/env perl
2use strict;
3use warnings;
Akrondcbee642020-10-30 18:01:43 +01004use KorAP::XML::Annotation::Malt::Dependency;
Akron194be542016-01-21 12:52:43 +01005use utf8;
Akronf3f0c942016-06-27 13:27:14 +02006use Log::Log4perl;
7
8Log::Log4perl->init({
Akrona5920b12016-06-29 18:51:21 +02009 'log4perl.rootLogger' => 'ERROR, STDERR',
Akronf3f0c942016-06-27 13:27:14 +020010 'log4perl.appender.STDERR' => 'Log::Log4perl::Appender::ScreenColoredLevels',
11 'log4perl.appender.STDERR.layout' => 'PatternLayout',
12 'log4perl.appender.STDERR.layout.ConversionPattern' => '[%r] %F %L %c - %m%n'
13});
14
15use Test::More;
Akron194be542016-01-21 12:52:43 +010016use Scalar::Util qw/weaken/;
17use Data::Dumper;
Akron151676d2016-03-14 20:12:14 +010018use lib 't/annotation';
Akron194be542016-01-21 12:52:43 +010019use TestInit;
20
Akron194be542016-01-21 12:52:43 +010021
Akronf3f0c942016-06-27 13:27:14 +020022
23use_ok('KorAP::XML::Annotation::Malt::Dependency');
24
25ok(my $tokens = TestInit::tokens('0002', 'Tree_Tagger'), 'Parse tokens');
26
27ok($tokens->add('Malt', 'Dependency'), 'Add Dependency');
Akron194be542016-01-21 12:52:43 +010028
29my $data = $tokens->to_data->{data};
30
Akronf3f0c942016-06-27 13:27:14 +020031is($data->{tokenSource}, 'tree_tagger#tokens', 'TokenSource');
32like($data->{foundries}, qr!malt/dependency!, 'foundries');
33like($data->{layerInfos}, qr!malt/d=rels!, 'foundries');
34
35my $stream = $data->{stream};
36
37is($stream->[0]->[0], '-:tokens$<i>31', 'Number of paragraphs');
38
39# Term2Term relation
40is($stream->[0]->[1], '<:malt/d:KON$<b>32<i>1', 'Term2Term relation');
Akrond19e2752017-11-16 15:48:26 +010041is($stream->[0]->[-1], 's:Maximen', 'Surface');
42
Akronf3f0c942016-06-27 13:27:14 +020043is($stream->[1]->[0], '>:malt/d:KON$<b>32<i>0', 'Term2Term relation');
Akrond19e2752017-11-16 15:48:26 +010044is($stream->[1]->[-1], 's:und', 'Surface');
Akronf3f0c942016-06-27 13:27:14 +020045
46is($stream->[0]->[2], '<:malt/d:KON$<b>32<i>3', 'Term2Term relation');
47is($stream->[3]->[0], '>:malt/d:KON$<b>32<i>0', 'Term2Term relation');
Akrond19e2752017-11-16 15:48:26 +010048is($stream->[3]->[-1], 's:Religion', 'Term2Term relation');
Akronf3f0c942016-06-27 13:27:14 +020049
50# Term2Element and Element2Term relation
51is($stream->[0]->[3], '<:malt/d:ROOT$<b>34<i>0<i>49<i>6<i>0', 'Term2Term relation');
52is($stream->[0]->[5], '>:malt/d:ROOT$<b>33<i>0<i>49<i>0<i>6', 'Term2Term relation');
53
54# Text element
Akrondec43122020-03-03 11:22:25 +010055is($stream->[0]->[4], '<>:base/s:t$<b>64<i>0<i>238<i>31<b>0', 'Text element');
Akron14ca9f02016-01-29 19:38:18 +010056
Akron194be542016-01-21 12:52:43 +010057done_testing;
58__END__