Akron | eb12e23 | 2021-02-25 13:49:50 +0100 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | |
| 4 | use FindBin; |
| 5 | BEGIN { |
| 6 | unshift @INC, "$FindBin::Bin/../lib"; |
| 7 | }; |
| 8 | |
| 9 | use Test::More; |
| 10 | use Test::XML::Loy; |
| 11 | use_ok('KorAP::XML::TEI::Inline'); |
| 12 | |
| 13 | |
| 14 | my $inline = KorAP::XML::TEI::Inline->new; |
| 15 | |
| 16 | ok($inline->parse('aaa', \'Der <b>alte</b> Mann'), 'Parsed'); |
| 17 | |
| 18 | is($inline->data->data, 'Der alte Mann'); |
| 19 | |
| 20 | Test::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 | |
| 30 | Test::XML::Loy->new($inline->tokens->to_string('aaa', 0)) |
| 31 | ->element_exists_not('fs') |
| 32 | ; |
| 33 | |
| 34 | |
| 35 | ok($inline->parse('aaa', \'<w>Die</w> <w>alte</w> <w>Frau</w>'), 'Parsed'); |
| 36 | |
| 37 | is($inline->data->data, 'Die alte Frau'); |
| 38 | |
| 39 | Test::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 | |
| 59 | Test::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 | |
| 72 | ok($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 | |
| 75 | is($inline->data->data, 'Die alte Frau'); |
| 76 | |
| 77 | Test::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 | |
| 97 | done_testing; |