blob: 7fa23576408e4cf941e8162a0d6f411ecb469e44 [file] [log] [blame]
Akroneb12e232021-02-25 13:49:50 +01001use strict;
2use warnings;
3
4use FindBin;
5BEGIN {
6 unshift @INC, "$FindBin::Bin/../lib";
7};
8
9use Test::More;
10use Test::XML::Loy;
11use_ok('KorAP::XML::TEI::Inline');
12
13
14my $inline = KorAP::XML::TEI::Inline->new;
15
16ok($inline->parse('aaa', \'Der <b>alte</b> Mann'), 'Parsed');
17
18is($inline->data->data, 'Der alte Mann');
19
20Test::XML::Loy->new($inline->structures->to_string('aaa', 2))
21 ->attr_is('#s0', 'l', "1")
22 ->attr_is('#s0', 'to', 13)
23 ->text_is('#s0 fs f[name=name]', 'text')
24 ->attr_is('#s1', 'l', "2")
25 ->attr_is('#s1', 'from', 4)
26 ->attr_is('#s1', 'to', 8)
27 ->text_is('#s1 fs f[name=name]', 'b')
28 ;
29
30Test::XML::Loy->new($inline->tokens->to_string('aaa', 0))
31 ->element_exists_not('fs')
32 ;
33
34
35ok($inline->parse('aaa', \'<w>Die</w> <w>alte</w> <w>Frau</w>'), 'Parsed');
36
37is($inline->data->data, 'Die alte Frau');
38
39Test::XML::Loy->new($inline->structures->to_string('aaa', 2))
40 ->attr_is('#s0', 'l', "1")
41 ->attr_is('#s0', 'to', 13)
42 ->text_is('#s0 fs f[name=name]', 'text')
43
44 ->attr_is('#s1', 'l', "2")
45 ->attr_is('#s1', 'to', 3)
46 ->text_is('#s1 fs f[name=name]', 'w')
47
48 ->attr_is('#s2', 'l', "2")
49 ->attr_is('#s2', 'from', 4)
50 ->attr_is('#s2', 'to', 8)
51 ->text_is('#s2 fs f[name=name]', 'w')
52
53 ->attr_is('#s3', 'l', "2")
54 ->attr_is('#s3', 'from', 9)
55 ->attr_is('#s3', 'to', 13)
56 ->text_is('#s3 fs f[name=name]', 'w')
57 ;
58
59Test::XML::Loy->new($inline->tokens->to_string('aaa', 0))
60 ->attr_is('#s0', 'l', "2")
61 ->attr_is('#s0', 'to', 3)
62
63 ->attr_is('#s1', 'l', "2")
64 ->attr_is('#s1', 'from', 4)
65 ->attr_is('#s1', 'to', 8)
66
67 ->attr_is('#s2', 'l', "2")
68 ->attr_is('#s2', 'from', 9)
69 ->attr_is('#s2', 'to', 13)
70 ;
71
72ok($inline->parse('aaa', \'<w lemma="die" type="det">Die</w> <w
73 lemma="alt" type="ADJ">alte</w> <w lemma="frau" type="NN">Frau</w>'), 'Parsed');
74
75is($inline->data->data, 'Die alte Frau');
76
77Test::XML::Loy->new($inline->tokens->to_string('aaa', 1))
78 ->attr_is('#s0', 'l', "2")
79 ->attr_is('#s0', 'to', 3)
80 ->text_is('#s0 fs f[name="lemma"]', 'die')
81 ->text_is('#s0 fs f[name="type"]', 'det')
82
83 ->attr_is('#s1', 'l', "2")
84 ->attr_is('#s1', 'from', 4)
85 ->attr_is('#s1', 'to', 8)
86 ->text_is('#s1 fs f[name="lemma"]', 'alt')
87 ->text_is('#s1 fs f[name="type"]', 'ADJ')
88
89 ->attr_is('#s2', 'l', "2")
90 ->attr_is('#s2', 'from', 9)
91 ->attr_is('#s2', 'to', 13)
92 ->text_is('#s2 fs f[name="lemma"]', 'frau')
93 ->text_is('#s2 fs f[name="type"]', 'NN')
94 ;
95
96
97done_testing;