Akron | 194be54 | 2016-01-21 12:52:43 +0100 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | use utf8; |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 5 | use Log::Log4perl; |
| 6 | |
| 7 | Log::Log4perl->init({ |
| 8 | 'log4perl.rootLogger' => 'DEBUG, STDERR', |
| 9 | 'log4perl.appender.STDERR' => 'Log::Log4perl::Appender::ScreenColoredLevels', |
| 10 | 'log4perl.appender.STDERR.layout' => 'PatternLayout', |
| 11 | 'log4perl.appender.STDERR.layout.ConversionPattern' => '[%r] %F %L %c - %m%n' |
| 12 | }); |
| 13 | |
| 14 | use Test::More; |
Akron | 194be54 | 2016-01-21 12:52:43 +0100 | [diff] [blame] | 15 | use Scalar::Util qw/weaken/; |
| 16 | use Data::Dumper; |
Akron | 151676d | 2016-03-14 20:12:14 +0100 | [diff] [blame] | 17 | use lib 't/annotation'; |
Akron | 194be54 | 2016-01-21 12:52:43 +0100 | [diff] [blame] | 18 | use TestInit; |
| 19 | |
Akron | 194be54 | 2016-01-21 12:52:43 +0100 | [diff] [blame] | 20 | |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 21 | |
| 22 | use_ok('KorAP::XML::Annotation::Malt::Dependency'); |
| 23 | |
| 24 | ok(my $tokens = TestInit::tokens('0002', 'Tree_Tagger'), 'Parse tokens'); |
| 25 | |
| 26 | ok($tokens->add('Malt', 'Dependency'), 'Add Dependency'); |
Akron | 194be54 | 2016-01-21 12:52:43 +0100 | [diff] [blame] | 27 | |
| 28 | my $data = $tokens->to_data->{data}; |
| 29 | |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 30 | is($data->{tokenSource}, 'tree_tagger#tokens', 'TokenSource'); |
| 31 | like($data->{foundries}, qr!malt/dependency!, 'foundries'); |
| 32 | like($data->{layerInfos}, qr!malt/d=rels!, 'foundries'); |
| 33 | |
| 34 | my $stream = $data->{stream}; |
| 35 | |
| 36 | is($stream->[0]->[0], '-:tokens$<i>31', 'Number of paragraphs'); |
| 37 | |
| 38 | # Term2Term relation |
| 39 | is($stream->[0]->[1], '<:malt/d:KON$<b>32<i>1', 'Term2Term relation'); |
| 40 | is($stream->[1]->[0], '>:malt/d:KON$<b>32<i>0', 'Term2Term relation'); |
| 41 | |
| 42 | is($stream->[0]->[2], '<:malt/d:KON$<b>32<i>3', 'Term2Term relation'); |
| 43 | is($stream->[3]->[0], '>:malt/d:KON$<b>32<i>0', 'Term2Term relation'); |
| 44 | |
| 45 | # Term2Element and Element2Term relation |
| 46 | is($stream->[0]->[3], '<:malt/d:ROOT$<b>34<i>0<i>49<i>6<i>0', 'Term2Term relation'); |
| 47 | is($stream->[0]->[5], '>:malt/d:ROOT$<b>33<i>0<i>49<i>0<i>6', 'Term2Term relation'); |
| 48 | |
| 49 | # Text element |
| 50 | is($stream->[0]->[4], '<>:base/s:t$<b>64<i>0<i>238<i>30<b>0', 'Text element'); |
Akron | 14ca9f0 | 2016-01-29 19:38:18 +0100 | [diff] [blame] | 51 | |
Akron | 194be54 | 2016-01-21 12:52:43 +0100 | [diff] [blame] | 52 | done_testing; |
| 53 | __END__ |
| 54 | |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 55 | diag $data; |
Akron | 194be54 | 2016-01-21 12:52:43 +0100 | [diff] [blame] | 56 | |
Akron | 194be54 | 2016-01-21 12:52:43 +0100 | [diff] [blame] | 57 | |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 58 | |
| 59 | |
Akron | 194be54 | 2016-01-21 12:52:43 +0100 | [diff] [blame] | 60 | is($data->{stream}->[0]->[2], '<>:xip/s:s$<b>64<i>0<i>129<i>17<b>0', 'Text'); |
| 61 | is($data->{stream}->[0]->[3], '_0$<i>0<i>3', 'Position'); |
| 62 | is($data->{stream}->[-1]->[0], '_17$<i>124<i>128', 'Position'); |
| 63 | |