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({ |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 8 | 'log4perl.rootLogger' => 'ERROR, STDERR', |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 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'); |
Akron | d19e275 | 2017-11-16 15:48:26 +0100 | [diff] [blame] | 40 | is($stream->[0]->[-1], 's:Maximen', 'Surface'); |
| 41 | |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 42 | is($stream->[1]->[0], '>:malt/d:KON$<b>32<i>0', 'Term2Term relation'); |
Akron | d19e275 | 2017-11-16 15:48:26 +0100 | [diff] [blame] | 43 | is($stream->[1]->[-1], 's:und', 'Surface'); |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 44 | |
| 45 | is($stream->[0]->[2], '<:malt/d:KON$<b>32<i>3', 'Term2Term relation'); |
| 46 | is($stream->[3]->[0], '>:malt/d:KON$<b>32<i>0', 'Term2Term relation'); |
Akron | d19e275 | 2017-11-16 15:48:26 +0100 | [diff] [blame] | 47 | is($stream->[3]->[-1], 's:Religion', 'Term2Term relation'); |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame] | 48 | |
| 49 | # Term2Element and Element2Term relation |
| 50 | is($stream->[0]->[3], '<:malt/d:ROOT$<b>34<i>0<i>49<i>6<i>0', 'Term2Term relation'); |
| 51 | is($stream->[0]->[5], '>:malt/d:ROOT$<b>33<i>0<i>49<i>0<i>6', 'Term2Term relation'); |
| 52 | |
| 53 | # Text element |
| 54 | 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] | 55 | |
Akron | 194be54 | 2016-01-21 12:52:43 +0100 | [diff] [blame] | 56 | done_testing; |
| 57 | __END__ |