Split out structure parsing
Change-Id: Ia38a8c7f588c5361bebbcc7350c18f1540357757
diff --git a/t/token.t b/t/annotation.t
similarity index 92%
rename from t/token.t
rename to t/annotation.t
index 85bab65..1176c98 100644
--- a/t/token.t
+++ b/t/annotation.t
@@ -8,10 +8,10 @@
unshift @INC, "$FindBin::Bin/../lib";
};
-use_ok('KorAP::XML::TEI::Tokenizer::Token');
+use_ok('KorAP::XML::TEI::Annotations::Annotation');
subtest 'Initialization' => sub {
- my $t = KorAP::XML::TEI::Tokenizer::Token->new;
+ my $t = KorAP::XML::TEI::Annotations::Annotation->new;
ok(!defined($t->from), 'Undefined from');
ok(!defined($t->to), 'Undefined to');
@@ -52,7 +52,7 @@
subtest 'Test inline annotations' => sub {
- my $t = KorAP::XML::TEI::Tokenizer::Token->new('x1', 0, 6);
+ my $t = KorAP::XML::TEI::Annotations::Annotation->new('x1', 0, 6);
$t->add_attribute('ana' => 'DET @PREMOD');
$t->add_attribute('lemma' => 'C & A');
diff --git a/t/annotations-collect.t b/t/annotations-collect.t
new file mode 100644
index 0000000..1a8c45f
--- /dev/null
+++ b/t/annotations-collect.t
@@ -0,0 +1,60 @@
+use strict;
+use warnings;
+use Test::More;
+use Test::XML::Loy;
+
+use FindBin;
+BEGIN {
+ unshift @INC, "$FindBin::Bin/../lib";
+};
+
+use_ok('KorAP::XML::TEI::Annotations::Collector');
+use_ok('KorAP::XML::TEI::Annotations::Annotation');
+
+my $t = KorAP::XML::TEI::Annotations::Collector->new;
+
+$t->add_new_annotation('x1',0,8);
+my $token = $t->add_new_annotation('x2',9,14,2);
+$t->add_new_annotation('x3',15,20);
+
+my $loy = Test::XML::Loy->new($token->to_string(2));
+
+$loy->attr_is('span', 'id', 's2')
+ ->attr_is('span', 'from', 9)
+ ->attr_is('span', 'to', 14)
+ ->attr_is('span', 'l', 2)
+ ->attr_is('span fs f', 'name', 'lex')
+ ;
+
+$loy = Test::XML::Loy->new($t->last_token->to_string(3));
+
+$loy->attr_is('span', 'id', 's3')
+ ->attr_is('span', 'from', 15)
+ ->attr_is('span', 'to', 20)
+ ->attr_is('span fs f', 'name', 'lex')
+;
+
+$loy = Test::XML::Loy->new($t->to_string('text', 0))
+ ->attr_is('layer', 'docid', 'text')
+ ->attr_is('span#s0', 'to', '8')
+ ->attr_is('span#s1', 'to', '14')
+ ->attr_is('span#s1', 'l', '2')
+ ->attr_is('span#s2', 'to', '20')
+;
+
+my $anno = KorAP::XML::TEI::Annotations::Annotation->new('x4', 20 => 21);
+
+$t->add_annotation($anno);
+
+$loy = Test::XML::Loy->new($t->to_string('text',0))
+ ->attr_is('layer', 'docid', 'text')
+ ->attr_is('span#s0', 'to', '8')
+ ->attr_is('span#s1', 'to', '14')
+ ->attr_is('span#s1', 'l', '2')
+ ->attr_is('span#s2', 'to', '20')
+ ->attr_is('span#s3', 'from', '20')
+ ->attr_is('span#s3', 'to', '21')
+;
+
+done_testing;
+
diff --git a/t/tokenization-collect.t b/t/tokenization-collect.t
deleted file mode 100644
index 952c4b7..0000000
--- a/t/tokenization-collect.t
+++ /dev/null
@@ -1,46 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-use Test::XML::Loy;
-
-use FindBin;
-BEGIN {
- unshift @INC, "$FindBin::Bin/../lib";
-};
-
-use_ok('KorAP::XML::TEI::Tokenizer::Collector');
-
-my $t = KorAP::XML::TEI::Tokenizer::Collector->new;
-
-$t->add_token('x1',0,8);
-my $token = $t->add_token('x2',9,14,2);
-$t->add_token('x3',15,20);
-
-my $loy = Test::XML::Loy->new($token->to_string(2));
-
-$loy->attr_is('span', 'id', 's2')
- ->attr_is('span', 'from', 9)
- ->attr_is('span', 'to', 14)
- ->attr_is('span', 'l', 2)
- ->attr_is('span fs f', 'name', 'lex')
- ;
-
-$loy = Test::XML::Loy->new($t->last_token->to_string(3));
-
-$loy->attr_is('span', 'id', 's3')
- ->attr_is('span', 'from', 15)
- ->attr_is('span', 'to', 20)
- ->attr_is('span fs f', 'name', 'lex')
-;
-
-$loy = Test::XML::Loy->new($t->to_string('text', 0))
- ->attr_is('layer', 'docid', 'text')
- ->attr_is('span#s0', 'to', '8')
- ->attr_is('span#s1', 'to', '14')
- ->attr_is('span#s1', 'l', '2')
- ->attr_is('span#s2', 'to', '20')
-;
-
-
-done_testing;
-