blob: 1a8c45ff7bfb22159dee80da8388974eb4ffaa44 [file] [log] [blame]
Akron7501ca02020-08-01 21:05:25 +02001use strict;
2use warnings;
3use Test::More;
4use Test::XML::Loy;
5
6use FindBin;
7BEGIN {
8 unshift @INC, "$FindBin::Bin/../lib";
9};
10
11use_ok('KorAP::XML::TEI::Annotations::Collector');
12use_ok('KorAP::XML::TEI::Annotations::Annotation');
13
14my $t = KorAP::XML::TEI::Annotations::Collector->new;
15
16$t->add_new_annotation('x1',0,8);
17my $token = $t->add_new_annotation('x2',9,14,2);
18$t->add_new_annotation('x3',15,20);
19
20my $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
29$loy = Test::XML::Loy->new($t->last_token->to_string(3));
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
45my $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
59done_testing;
60