Akron | 7501ca0 | 2020-08-01 21:05:25 +0200 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
| 4 | use Test::XML::Loy; |
| 5 | |
| 6 | use FindBin; |
| 7 | BEGIN { |
| 8 | unshift @INC, "$FindBin::Bin/../lib"; |
| 9 | }; |
| 10 | |
| 11 | use_ok('KorAP::XML::TEI::Annotations::Collector'); |
| 12 | use_ok('KorAP::XML::TEI::Annotations::Annotation'); |
| 13 | |
| 14 | my $t = KorAP::XML::TEI::Annotations::Collector->new; |
| 15 | |
| 16 | $t->add_new_annotation('x1',0,8); |
| 17 | my $token = $t->add_new_annotation('x2',9,14,2); |
| 18 | $t->add_new_annotation('x3',15,20); |
| 19 | |
| 20 | my $loy = Test::XML::Loy->new($token->to_string(2)); |
| 21 | |
| 22 | $loy->attr_is('span', 'id', 's2') |
| 23 | ->attr_is('span', 'from', 9) |
| 24 | ->attr_is('span', 'to', 14) |
| 25 | ->attr_is('span', 'l', 2) |
| 26 | ->attr_is('span fs f', 'name', 'lex') |
| 27 | ; |
| 28 | |
Akron | 031a4f0 | 2020-09-29 08:04:14 +0200 | [diff] [blame] | 29 | $loy = Test::XML::Loy->new($t->[-1]->to_string(3)); |
Akron | 7501ca0 | 2020-08-01 21:05:25 +0200 | [diff] [blame] | 30 | |
| 31 | $loy->attr_is('span', 'id', 's3') |
| 32 | ->attr_is('span', 'from', 15) |
| 33 | ->attr_is('span', 'to', 20) |
| 34 | ->attr_is('span fs f', 'name', 'lex') |
| 35 | ; |
| 36 | |
| 37 | $loy = Test::XML::Loy->new($t->to_string('text', 0)) |
| 38 | ->attr_is('layer', 'docid', 'text') |
| 39 | ->attr_is('span#s0', 'to', '8') |
| 40 | ->attr_is('span#s1', 'to', '14') |
| 41 | ->attr_is('span#s1', 'l', '2') |
| 42 | ->attr_is('span#s2', 'to', '20') |
| 43 | ; |
| 44 | |
| 45 | my $anno = KorAP::XML::TEI::Annotations::Annotation->new('x4', 20 => 21); |
| 46 | |
| 47 | $t->add_annotation($anno); |
| 48 | |
| 49 | $loy = Test::XML::Loy->new($t->to_string('text',0)) |
| 50 | ->attr_is('layer', 'docid', 'text') |
| 51 | ->attr_is('span#s0', 'to', '8') |
| 52 | ->attr_is('span#s1', 'to', '14') |
| 53 | ->attr_is('span#s1', 'l', '2') |
| 54 | ->attr_is('span#s2', 'to', '20') |
| 55 | ->attr_is('span#s3', 'from', '20') |
| 56 | ->attr_is('span#s3', 'to', '21') |
| 57 | ; |
| 58 | |
| 59 | done_testing; |
| 60 | |