Akron | 797e807 | 2020-02-13 07:59:40 +0100 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use File::Basename 'dirname'; |
| 4 | use File::Spec::Functions qw/catfile/; |
Peter Harders | 1c5ce15 | 2020-07-22 18:02:50 +0200 | [diff] [blame] | 5 | use Encode qw!encode_utf8 decode_utf8 encode!; |
Akron | 797e807 | 2020-02-13 07:59:40 +0100 | [diff] [blame] | 6 | |
| 7 | use Test::More; |
| 8 | use Test::Output; |
Peter Harders | 42e18a6 | 2020-07-21 02:43:26 +0200 | [diff] [blame] | 9 | |
| 10 | use FindBin; |
| 11 | BEGIN { |
| 12 | unshift @INC, "$FindBin::Bin/../lib"; |
| 13 | }; |
Peter Harders | 1c5ce15 | 2020-07-22 18:02:50 +0200 | [diff] [blame] | 14 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 15 | use Test::KorAP::XML::TEI qw!korap_tempfile i5_template test_tei2korapxml!; |
Peter Harders | 57c884e | 2020-07-16 01:28:52 +0200 | [diff] [blame] | 16 | |
Akron | 797e807 | 2020-02-13 07:59:40 +0100 | [diff] [blame] | 17 | my $f = dirname(__FILE__); |
| 18 | my $script = catfile($f, '..', 'script', 'tei2korapxml'); |
| 19 | ok(-f $script, 'Script found'); |
| 20 | |
Akron | d949e18 | 2020-02-14 12:23:57 +0100 | [diff] [blame] | 21 | stdout_like( |
Akron | 797e807 | 2020-02-13 07:59:40 +0100 | [diff] [blame] | 22 | sub { system('perl', $script, '--help') }, |
Akron | d949e18 | 2020-02-14 12:23:57 +0100 | [diff] [blame] | 23 | qr!This\s*program\s*is\s*usually\s*called\s*from\s*inside\s*another\s*script\.!, |
Akron | 797e807 | 2020-02-13 07:59:40 +0100 | [diff] [blame] | 24 | 'Help' |
| 25 | ); |
| 26 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 27 | |
Akron | d949e18 | 2020-02-14 12:23:57 +0100 | [diff] [blame] | 28 | stdout_like( |
| 29 | sub { system('perl', $script, '--version') }, |
| 30 | qr!tei2korapxml - v\d+?\.\d+?!, |
| 31 | 'Version' |
| 32 | ); |
| 33 | |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 34 | # Load example file |
| 35 | my $file = catfile($f, 'data', 'goe_sample.i5.xml'); |
Peter Harders | 57c884e | 2020-07-16 01:28:52 +0200 | [diff] [blame] | 36 | |
Akron | b364947 | 2020-09-29 08:24:46 +0200 | [diff] [blame] | 37 | subtest 'Debugging' => sub { |
| 38 | |
| 39 | my $t = test_tei2korapxml( |
| 40 | tmp => 'script_out', |
| 41 | file => $file, |
| 42 | param => '-ti', |
| 43 | env => 'KORAPXMLTEI_DEBUG=1' |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 44 | )->stderr_like(qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!) |
Akron | b364947 | 2020-09-29 08:24:46 +0200 | [diff] [blame] | 45 | ->stderr_like(qr!Debugging is activated!); |
| 46 | }; |
| 47 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 48 | subtest 'Basic processing' => sub { |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 49 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 50 | my $t = test_tei2korapxml( |
| 51 | tmp => 'script_out', |
| 52 | file => $file, |
| 53 | param => '-ti' |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 54 | )->stderr_like(qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!) |
Akron | b364947 | 2020-09-29 08:24:46 +0200 | [diff] [blame] | 55 | ->stderr_unlike(qr!Debugging is activated!); |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 56 | |
Akron | 6896608 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 57 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 58 | # Uncompress GOE/header.xml from zip file |
| 59 | $t->unzip_xml('GOE/header.xml') |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 60 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 61 | # TODO: check wrong encoding in header-files (compare with input document)! |
| 62 | ->text_is('korpusSigle', 'GOE', 'korpusSigle') |
| 63 | ->text_is('h\.title[type=main]', 'Goethes Werke', 'h.title') |
| 64 | ->text_is('h\.author', 'Goethe, Johann Wolfgang von', 'h.author') |
| 65 | ->text_is('pubDate[type=year]', '1982', 'pubDate'); |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 66 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 67 | # Uncompress GOE/AGA/header.xml from zip file |
| 68 | $t->unzip_xml('GOE/AGA/header.xml') |
| 69 | ->text_is('dokumentSigle', 'GOE/AGA', 'dokumentSigle') |
| 70 | ->text_is('d\.title', 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)', 'd.title') |
| 71 | ->text_is('creatDate', '1820-1822', 'creatDate'); |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 72 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 73 | # Uncompress GOE/AGA/00000/header.xml from zip file |
| 74 | $t->unzip_xml('GOE/AGA/00000/header.xml') |
| 75 | ->text_is('textSigle', 'GOE/AGA.00000', 'textSigle') |
| 76 | ->text_is('analytic > h\.title[type=main]', 'Campagne in Frankreich', 'h.title'); |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 77 | |
| 78 | # Uncompress GOE/AGA/00000/data.xml from zip file |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 79 | $t->unzip_xml('GOE/AGA/00000/data.xml') |
| 80 | ->attr_is('raw_text', 'docid', 'GOE_AGA.00000', 'text id') |
Marc Kupietz | fd0e6a9 | 2020-09-09 18:07:29 +0200 | [diff] [blame] | 81 | ->text_like('raw_text > text', qr!^Campagne in Frankreich 1792.*?uns allein begl.*cke\.$!, 'text content') |
| 82 | ->text_like('raw_text > text', qr!unter dem Titel "Kriegstheater"!, 'text content'); |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 83 | |
Akron | 417ed2f | 2020-09-28 12:43:17 +0200 | [diff] [blame] | 84 | my $content = $t->get_content_of('GOE/AGA/00000/data.xml'); |
| 85 | like($content, qr!unter dem Titel "Kriegstheater"!, 'raw text content'); |
| 86 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 87 | $t->unzip_xml('GOE/AGA/00000/struct/structure.xml') |
Akron | c57625b | 2020-07-30 11:46:06 +0200 | [diff] [blame] | 88 | ->text_is('span[id=s3] *[name=type]', 'Autobiographie', 'text content') |
| 89 | ->text_is('#s3 *[name=type]', 'Autobiographie', 'text content') |
| 90 | ->attr_is('#s0','to','1266') |
| 91 | ->attr_is('#s0','l','1') |
| 92 | |
| 93 | ->attr_is('#s18','from','925') |
| 94 | ->attr_is('#s18','to','1266') |
| 95 | ->attr_is('#s18','l','5') |
| 96 | ->attr_is('#s18 > fs','type', 'struct') |
| 97 | ->attr_is('#s18 > fs > f','name','name') |
| 98 | ->text_is('#s18 > fs > f','poem') |
| 99 | |
| 100 | ->attr_is('#s19','from','925') |
| 101 | ->attr_is('#s19','to','1098') |
| 102 | ->attr_is('#s19','l','6') |
| 103 | ->attr_is('#s19 > fs','type','struct') |
| 104 | ->text_is('#s19 > fs > f[name=name]','lg') |
| 105 | ->text_is('#s19 > fs > f[name=attr] > fs[type=attr] >f[name=part]','u') |
| 106 | |
| 107 | ->attr_is('#s37','from','1229') |
| 108 | ->attr_is('#s37','to','1266') |
| 109 | ->attr_is('#s37','l','8') |
| 110 | ->attr_is('#s37 > fs','type','struct') |
| 111 | ->text_is('#s37 > fs > f[name=name]','s') |
| 112 | ->text_is('#s37 > fs > f[name=attr] > fs[type=attr] > f[name=type]','manual') |
| 113 | |
| 114 | ->attr_is('#s38','from','1266') |
| 115 | ->attr_is('#s38','to','1266') |
| 116 | ->attr_is('#s38','l','2') |
| 117 | ->attr_is('#s38 > fs','type','struct') |
| 118 | ->text_is('#s38 > fs > f[name=name]','back') |
Akron | f7084c4 | 2021-01-07 10:25:22 +0100 | [diff] [blame] | 119 | ->element_count_is('*', 196); |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 120 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 121 | $t->file_exists_not('GOE/AGA/00000/base/tokens.xml', 'External not generated'); |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 122 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 123 | # Uncompress GOE/AGA/00000/base/tokens_aggressive.xml from zip file |
| 124 | $t->unzip_xml('GOE/AGA/00000/base/tokens_aggressive.xml') |
| 125 | ->attr_is('spanList span:nth-child(1)', 'to', 8) |
| 126 | ->attr_is('spanList span#t_1', 'from', 9) |
| 127 | ->attr_is('spanList span#t_1', 'to', 11) |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 128 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 129 | ->attr_is('spanList span#t_67', 'from', 427) |
| 130 | ->attr_is('spanList span#t_67', 'to', 430) |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 131 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 132 | ->attr_is('spanList span#t_214', 'from', 1209) |
| 133 | ->attr_is('spanList span#t_214', 'to', 1212) |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 134 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 135 | ->element_count_is('spanList span', 227); |
Peter Harders | 57c884e | 2020-07-16 01:28:52 +0200 | [diff] [blame] | 136 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 137 | # Uncompress GOE/AGA/00000/base/tokens_conservative.xml from zip file |
| 138 | $t->unzip_xml('GOE/AGA/00000/base/tokens_conservative.xml') |
| 139 | ->attr_is('spanList span:nth-child(1)', 'to', 8) |
Akron | 2a60c53 | 2020-02-13 15:52:18 +0100 | [diff] [blame] | 140 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 141 | ->attr_is('spanList span#t_1', 'from', 9) |
| 142 | ->attr_is('spanList span#t_1', 'to', 11) |
Akron | 797e807 | 2020-02-13 07:59:40 +0100 | [diff] [blame] | 143 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 144 | ->attr_is('spanList span#t_67', 'from', 427) |
| 145 | ->attr_is('spanList span#t_67', 'to', 430) |
Akron | eac374d | 2020-07-07 09:00:44 +0200 | [diff] [blame] | 146 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 147 | ->attr_is('spanList span#t_214', 'from', 1209) |
| 148 | ->attr_is('spanList span#t_214', 'to', 1212) |
Akron | eac374d | 2020-07-07 09:00:44 +0200 | [diff] [blame] | 149 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 150 | ->element_count_is('spanList span', 227); |
| 151 | }; |
Akron | eac374d | 2020-07-07 09:00:44 +0200 | [diff] [blame] | 152 | |
Akron | eac374d | 2020-07-07 09:00:44 +0200 | [diff] [blame] | 153 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 154 | subtest 'Tokenize with external tokenizer' => sub { |
Akron | eac374d | 2020-07-07 09:00:44 +0200 | [diff] [blame] | 155 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 156 | my $cmd = catfile($f, 'cmd', 'tokenizer.pl'); |
Akron | eac374d | 2020-07-07 09:00:44 +0200 | [diff] [blame] | 157 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 158 | test_tei2korapxml( |
| 159 | file => $file, |
| 160 | param => "-tc='perl $cmd'", |
| 161 | tmp => 'script_out2' |
| 162 | ) |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 163 | ->stderr_like(qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!) |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 164 | ->file_readable('GOE/AGA/00000/base/tokens.xml') |
Akron | eac374d | 2020-07-07 09:00:44 +0200 | [diff] [blame] | 165 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 166 | # Uncompress GOE/AGA/00000/base/tokens.xml from zip file |
| 167 | ->unzip_xml('GOE/AGA/00000/base/tokens.xml') |
| 168 | ->attr_is('spanList span:nth-child(1)', 'to', 8) |
| 169 | ->attr_is('spanList span#t_1', 'from', 9) |
| 170 | ->attr_is('spanList span#t_1', 'to', 11) |
| 171 | ->attr_is('spanList span#t_67', 'from', 427) |
| 172 | ->attr_is('spanList span#t_67', 'to', 430) |
| 173 | ->attr_is('spanList span#t_214', 'from', 1209) |
| 174 | ->attr_is('spanList span#t_214', 'to', 1212) |
| 175 | ->element_count_is('spanList span', 227); |
| 176 | }; |
Akron | eac374d | 2020-07-07 09:00:44 +0200 | [diff] [blame] | 177 | |
Marc Kupietz | eed4cb1 | 2021-02-17 19:39:32 +0100 | [diff] [blame] | 178 | subtest 'Check KorAP tokenizer for infinite loop bug' => sub { |
| 179 | |
| 180 | my $file = catfile($f, 'data', 'korap_tokenizer_challenge.xml'); |
| 181 | |
| 182 | eval { |
| 183 | require KorAP::XML::TEI::Tokenizer::KorAP; |
| 184 | 1; |
| 185 | } or do { |
| 186 | plan skip_all => "KorAP::XML::TEI::Tokenizer::KorAP cannot be used"; |
| 187 | }; |
| 188 | |
| 189 | test_tei2korapxml( |
| 190 | file => $file, |
| 191 | param => "-tk -s", |
| 192 | tmp => 'script_bug_check' |
| 193 | ) |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 194 | ->stderr_like(qr!tei2korapxml:.*? text_id=WDD19_H0039\.87242!) |
Marc Kupietz | eed4cb1 | 2021-02-17 19:39:32 +0100 | [diff] [blame] | 195 | ->file_readable('WDD19/H0039/87242/struct/structure.xml'); |
| 196 | }; |
| 197 | |
Marc Kupietz | 985da0c | 2021-02-15 19:29:50 +0100 | [diff] [blame] | 198 | subtest 'Sentence split with KorAP tokenizer' => sub { |
| 199 | |
| 200 | eval { |
| 201 | require KorAP::XML::TEI::Tokenizer::KorAP; |
| 202 | 1; |
| 203 | } or do { |
| 204 | plan skip_all => "KorAP::XML::TEI::Tokenizer::KorAP cannot be used"; |
| 205 | }; |
| 206 | |
| 207 | test_tei2korapxml( |
| 208 | file => $file, |
| 209 | param => "-tk -s", |
| 210 | tmp => 'script_sentence_split' |
| 211 | ) |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 212 | ->stderr_like(qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!) |
Marc Kupietz | 985da0c | 2021-02-15 19:29:50 +0100 | [diff] [blame] | 213 | ->file_readable('GOE/AGA/00000/struct/structure.xml') |
| 214 | ->unzip_xml('GOE/AGA/00000/struct/structure.xml') |
| 215 | ->text_is('span#s25 fs f', 's') |
| 216 | ->attr_is('span#s25', 'l', -1) |
| 217 | ->attr_is('span#s25', 'to', 54) |
| 218 | ->text_is('span#s30 fs f', 's') |
| 219 | ->attr_is('span#s30', 'l', -1) |
| 220 | ->attr_is('span#s30', 'from', 1099) |
| 221 | ->attr_is('span#s30', 'to', 1266); |
| 222 | }; |
Akron | eac374d | 2020-07-07 09:00:44 +0200 | [diff] [blame] | 223 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 224 | subtest 'Test Tokenizations' => sub { |
Akron | eac374d | 2020-07-07 09:00:44 +0200 | [diff] [blame] | 225 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 226 | my $t = test_tei2korapxml( |
| 227 | file => catfile($f, 'data', 'text_with_blanks.i5.xml'), |
| 228 | tmp => 'script_out3', |
| 229 | param => '-ti' |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 230 | )->stderr_like(qr!tei2korapxml:.*? text_id=CORP_DOC.00001!); |
Akron | 8b511f9 | 2020-07-09 17:28:08 +0200 | [diff] [blame] | 231 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 232 | # ~ test conservative tokenization ~ |
| 233 | $t->unzip_xml('CORP/DOC/00001/base/tokens_conservative.xml') |
| 234 | ->attr_is('spanList span:nth-child(1)', 'to', 6) |
Akron | 8b511f9 | 2020-07-09 17:28:08 +0200 | [diff] [blame] | 235 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 236 | ->attr_is('spanList span#t_1', 'from', 7) |
| 237 | ->attr_is('spanList span#t_1', 'to', 9) |
Akron | 8b511f9 | 2020-07-09 17:28:08 +0200 | [diff] [blame] | 238 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 239 | ->attr_is('spanList span#t_3', 'from', 12) |
| 240 | ->attr_is('spanList span#t_3', 'to', 16) |
Akron | 8b511f9 | 2020-07-09 17:28:08 +0200 | [diff] [blame] | 241 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 242 | ->attr_is('spanList span#t_9', 'from', 36) |
| 243 | ->attr_is('spanList span#t_9', 'to', 37) |
Akron | 8b511f9 | 2020-07-09 17:28:08 +0200 | [diff] [blame] | 244 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 245 | ->attr_is('spanList span#t_13', 'from', 44) |
| 246 | ->attr_is('spanList span#t_13', 'to', 45) # " |
Akron | 8b511f9 | 2020-07-09 17:28:08 +0200 | [diff] [blame] | 247 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 248 | ->attr_is('spanList span#t_14', 'from', 45) # twenty-two |
| 249 | ->attr_is('spanList span#t_14', 'to', 55) |
Peter Harders | 42e18a6 | 2020-07-21 02:43:26 +0200 | [diff] [blame] | 250 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 251 | ->attr_is('spanList span#t_15', 'from', 55) # " |
| 252 | ->attr_is('spanList span#t_15', 'to', 56) |
Akron | 8b511f9 | 2020-07-09 17:28:08 +0200 | [diff] [blame] | 253 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 254 | ->attr_is('spanList span#t_19', 'from', 66) |
| 255 | ->attr_is('spanList span#t_19', 'to', 67) |
Peter Harders | b122717 | 2020-07-21 02:12:10 +0200 | [diff] [blame] | 256 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 257 | ->element_count_is('spanList span', 20); |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 258 | |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 259 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 260 | # ~ test aggressive tokenization ~ |
| 261 | $t->unzip_xml('CORP/DOC/00001/base/tokens_aggressive.xml') |
| 262 | ->attr_is('spanList span:nth-child(1)', 'to', 6) |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 263 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 264 | ->attr_is('spanList span#t_1', 'from', 7) |
| 265 | ->attr_is('spanList span#t_1', 'to', 9) |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 266 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 267 | ->attr_is('spanList span#t_3', 'from', 12) |
| 268 | ->attr_is('spanList span#t_3', 'to', 16) |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 269 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 270 | ->attr_is('spanList span#t_9', 'from', 36) |
| 271 | ->attr_is('spanList span#t_9', 'to', 37) |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 272 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 273 | ->attr_is('spanList span#t_13', 'from', 44) |
| 274 | ->attr_is('spanList span#t_13', 'to', 45) # " |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 275 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 276 | ->attr_is('spanList span#t_14', 'from', 45) # twenty |
| 277 | ->attr_is('spanList span#t_14', 'to', 51) |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 278 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 279 | ->attr_is('spanList span#t_15', 'from', 51) # - |
| 280 | ->attr_is('spanList span#t_15', 'to', 52) |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 281 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 282 | ->attr_is('spanList span#t_16', 'from', 52) # two |
| 283 | ->attr_is('spanList span#t_16', 'to', 55) |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 284 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 285 | ->attr_is('spanList span#t_17', 'from', 55) # " |
| 286 | ->attr_is('spanList span#t_17', 'to', 56) |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 287 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 288 | ->attr_is('spanList span#t_21', 'from', 66) |
| 289 | ->attr_is('spanList span#t_21', 'to', 67) |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 290 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 291 | ->element_count_is('spanList span', 22); |
| 292 | }; |
Peter Harders | 71f072b | 2020-07-15 14:15:01 +0200 | [diff] [blame] | 293 | |
| 294 | |
Peter Harders | 42e18a6 | 2020-07-21 02:43:26 +0200 | [diff] [blame] | 295 | subtest 'Check Tokenization Flags' => sub { |
| 296 | |
| 297 | # Get external tokenizer |
| 298 | my $f = dirname(__FILE__); |
| 299 | my $cmd = catfile($f, 'cmd', 'tokenizer.pl'); |
| 300 | |
| 301 | # Load example file |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 302 | test_tei2korapxml( |
| 303 | file => catfile($f, 'data', 'goe_sample.i5.xml'), |
| 304 | param => "-ti -tc 'perl $cmd'", |
| 305 | tmp => 'script_tokflags' |
| 306 | ) |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 307 | ->stderr_like(qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!) |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 308 | ->file_exists('GOE/AGA/00000/base/tokens_aggressive.xml') |
| 309 | ->file_exists('GOE/AGA/00000/base/tokens_conservative.xml') |
| 310 | ->file_exists('GOE/AGA/00000/base/tokens.xml') |
| 311 | ; |
Peter Harders | 42e18a6 | 2020-07-21 02:43:26 +0200 | [diff] [blame] | 312 | }; |
| 313 | |
Peter Harders | 1c5ce15 | 2020-07-22 18:02:50 +0200 | [diff] [blame] | 314 | |
| 315 | subtest 'Test utf-8 handling' => sub { |
Peter Harders | 1c5ce15 | 2020-07-22 18:02:50 +0200 | [diff] [blame] | 316 | # Introduce invalid utf-8 characters |
| 317 | my $text_sigle; |
Akron | 54e363c | 2020-07-29 11:01:03 +0200 | [diff] [blame] | 318 | { |
| 319 | no warnings; |
| 320 | # $text_sigle printed to file, without encoding: Aþ¿¿¿¿¿A_Bþ¿¿¿¿¿B.Cþ¿¿¿¿¿C |
| 321 | # the utf8-sequence 'þ¿¿¿¿¿' encodes 32 bit of data (see 0x7FFF_FFFF in perlunicode) |
| 322 | $text_sigle = "A\x{FFFF_FFFF}A_B\x{FFFF_FFFF}B.C\x{FFFF_FFFF}C" |
| 323 | } |
| 324 | # If CHECK is 0, encoding and decoding replace any malformed character |
| 325 | # with a substitution character. |
Peter Harders | 1c5ce15 | 2020-07-22 18:02:50 +0200 | [diff] [blame] | 326 | # � = substitution character |
| 327 | my $text_sigle_lax = encode_utf8($text_sigle); |
| 328 | my $text_sigle_esc = encode('UTF-8', $text_sigle); |
| 329 | |
| 330 | is(length($text_sigle), 11); # A�A_B�B.C�C (char string => length(�) = 1) |
| 331 | is(length($text_sigle_lax), 29); # Aþ¿¿¿¿¿A_Bþ¿¿¿¿¿B.Cþ¿¿¿¿¿C (byte string) |
| 332 | is(length($text_sigle_esc), 17); # A�A_B�B.C�C (byte string => length(�) = 3) |
| 333 | |
Akron | 54e363c | 2020-07-29 11:01:03 +0200 | [diff] [blame] | 334 | |
| 335 | my $tpl; |
| 336 | { |
| 337 | no warnings; |
| 338 | $tpl = i5_template( |
| 339 | korpusSigle => "A\x{FFFF_FFFF}A", |
| 340 | dokumentSigle => "A\x{FFFF_FFFF}A_B\x{FFFF_FFFF}B", |
| 341 | text => "<p>d\x{FFFF_FFFF}d e\x{FFFF_FFFF}e f\x{FFFF_FFFF}f</p>", |
| 342 | textSigle => $text_sigle |
| 343 | ); |
| 344 | }; |
Peter Harders | 1c5ce15 | 2020-07-22 18:02:50 +0200 | [diff] [blame] | 345 | |
| 346 | my ($fh, $tplfile) = korap_tempfile('script_out4'); |
| 347 | binmode($fh); |
| 348 | print $fh encode_utf8($tpl); # => text_id=Aþ¿¿¿¿¿A_Bþ¿¿¿¿¿B.Cþ¿¿¿¿¿C |
| 349 | close($fh); |
| 350 | |
| 351 | my (undef, $outzip) = korap_tempfile('script_out5'); |
| 352 | |
Akron | 54e363c | 2020-07-29 11:01:03 +0200 | [diff] [blame] | 353 | # because output 'textid=...' goes to STDERR (see script/tei2korapxml) |
Akron | eaa9623 | 2020-10-15 17:06:15 +0200 | [diff] [blame] | 354 | binmode STDERR; |
Peter Harders | 1c5ce15 | 2020-07-22 18:02:50 +0200 | [diff] [blame] | 355 | |
| 356 | stderr_like( |
| 357 | sub { `cat '$tplfile' | perl '$script' -ti > '$outzip'` }, |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 358 | qr!tei2korapxml:.*? text_id=$text_sigle_esc!, # see above: print $fh encode_utf8($tpl); |
Peter Harders | 1c5ce15 | 2020-07-22 18:02:50 +0200 | [diff] [blame] | 359 | ); |
| 360 | }; |
| 361 | |
Akron | e68ec0c | 2020-07-28 18:06:19 +0200 | [diff] [blame] | 362 | |
Akron | dd0be8f | 2021-02-18 19:29:41 +0100 | [diff] [blame] | 363 | subtest 'Check structure parsing with defined foundry and folder' => sub { |
| 364 | # Load example file |
| 365 | my $file = catfile($f, 'data', 'goe_sample.i5.xml'); |
| 366 | |
| 367 | my $t = test_tei2korapxml( |
| 368 | tmp => 'script_out', |
| 369 | file => $file, |
| 370 | param => '-ti --inline-structures=myfoundry#mystr' |
| 371 | )->stderr_like(qr!tei2korapxml: .*? text_id=GOE_AGA\.00000!) |
| 372 | ->file_exists_not('GOE/AGA/00000/struct/structure.xml', 'Structure not generated') |
| 373 | ->unzip_xml('GOE/AGA/00000/myfoundry/mystr.xml') |
| 374 | ->text_is('span[id=s3] *[name=type]', 'Autobiographie', 'text content') |
| 375 | ->text_is('#s3 *[name=type]', 'Autobiographie', 'text content') |
| 376 | ->attr_is('#s0','to','1266') |
| 377 | ->attr_is('#s0','l','1') |
| 378 | ->attr_is('#s18','from','925') |
| 379 | ->attr_is('#s18','to','1266') |
| 380 | ->attr_is('#s18','l','5') |
| 381 | ; |
| 382 | |
| 383 | $t = test_tei2korapxml( |
| 384 | tmp => 'script_out', |
| 385 | file => $file, |
| 386 | param => '-ti --inline-structures=myfoundry' |
| 387 | )->stderr_like(qr!tei2korapxml: .*? text_id=GOE_AGA\.00000!) |
| 388 | ->file_exists_not('GOE/AGA/00000/struct/structure.xml', 'Structure not generated') |
| 389 | ->unzip_xml('GOE/AGA/00000/myfoundry/structure.xml') |
| 390 | ->text_is('span[id=s3] *[name=type]', 'Autobiographie', 'text content') |
| 391 | ->text_is('#s3 *[name=type]', 'Autobiographie', 'text content') |
| 392 | ->attr_is('#s0','to','1266') |
| 393 | ->attr_is('#s0','l','1') |
| 394 | ->attr_is('#s18','from','925') |
| 395 | ->attr_is('#s18','to','1266') |
| 396 | ->attr_is('#s18','l','5') |
| 397 | ; |
| 398 | }; |
| 399 | |
| 400 | |
Akron | e68ec0c | 2020-07-28 18:06:19 +0200 | [diff] [blame] | 401 | subtest 'Check Inline annotations' => sub { |
| 402 | |
| 403 | # Load example file |
| 404 | my $file = catfile($f, 'data', 'goe_sample_tagged.i5.xml'); |
| 405 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 406 | my $t = test_tei2korapxml( |
| 407 | file => $file, |
| 408 | env => 'KORAPXMLTEI_INLINE=1', |
| 409 | tmp => 'script_tagged' |
| 410 | ) |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 411 | ->stderr_like(qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!) |
Akron | e68ec0c | 2020-07-28 18:06:19 +0200 | [diff] [blame] | 412 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 413 | # Check zip using xml loy |
| 414 | ->unzip_xml('GOE/AGA/00000/tokens/morpho.xml') |
Akron | e68ec0c | 2020-07-28 18:06:19 +0200 | [diff] [blame] | 415 | |
Akron | 044bd92 | 2020-07-30 09:12:28 +0200 | [diff] [blame] | 416 | ->attr_is('layer', 'docid', 'GOE_AGA.00000') |
Akron | e68ec0c | 2020-07-28 18:06:19 +0200 | [diff] [blame] | 417 | ->attr_is('spanList span:nth-child(1)', 'id', 's0') |
| 418 | ->attr_is('spanList span:nth-child(1)', 'from', '75') |
| 419 | ->attr_is('spanList span:nth-child(1)', 'to', '81') |
| 420 | ->attr_is('spanList span:nth-child(1)', 'l', '7') |
| 421 | |
| 422 | ->attr_is('span#s0 > fs', 'type', 'lex') |
| 423 | ->attr_is('span#s0 > fs', 'xmlns', 'http://www.tei-c.org/ns/1.0') |
| 424 | ->attr_is('span#s0 > fs > f > fs > f:nth-child(1)', 'name', 'pos') |
| 425 | ->text_is('span#s0 > fs > f > fs > f:nth-child(1)', 'A') |
| 426 | ->attr_is('span#s0 > fs > f > fs > f:nth-child(2)', 'name', 'msd') |
| 427 | ->text_is('span#s0 > fs > f > fs > f:nth-child(2)', '@NH') |
| 428 | |
| 429 | ->attr_is('span#s25', 'from', '259') |
| 430 | ->attr_is('span#s25', 'to', '263') |
| 431 | ->attr_is('span#s25', 'l', '7') |
| 432 | ->attr_is('span#s25 > fs > f > fs > f:nth-child(1)', 'name', 'pos') |
| 433 | ->text_is('span#s25 > fs > f > fs > f:nth-child(1)', 'PRON') |
| 434 | ->attr_is('span#s25 > fs > f > fs > f:nth-child(2)', 'name', 'msd') |
| 435 | ->text_is('span#s25 > fs > f > fs > f:nth-child(2)', '@NH') |
| 436 | |
| 437 | ->attr_is('span#s58', 'from', '495') |
| 438 | ->attr_is('span#s58', 'to', '500') |
| 439 | ->attr_is('span#s58', 'l', '7') |
| 440 | ->attr_is('span#s58 > fs > f > fs > f:nth-child(1)', 'name', 'pos') |
| 441 | ->text_is('span#s58 > fs > f > fs > f:nth-child(1)', 'N') |
| 442 | ->attr_is('span#s58 > fs > f > fs > f:nth-child(2)', 'name', 'msd') |
| 443 | ->text_is('span#s58 > fs > f > fs > f:nth-child(2)', '@NH') |
| 444 | |
| 445 | ->attr_is('span#s119', 'from', '914') |
| 446 | ->attr_is('span#s119', 'to', '925') |
| 447 | ->attr_is('span#s119', 'l', '7') |
| 448 | ->attr_is('span#s119 > fs > f > fs > f:nth-child(1)', 'name', 'pos') |
| 449 | ->text_is('span#s119 > fs > f > fs > f:nth-child(1)', 'A') |
| 450 | ->attr_is('span#s119 > fs > f > fs > f:nth-child(2)', 'name', 'msd') |
| 451 | ->text_is('span#s119 > fs > f > fs > f:nth-child(2)', '@NH') |
| 452 | ->element_exists_not('span#s120') |
| 453 | ; |
| 454 | }; |
| 455 | |
Akron | 26a7152 | 2021-02-19 10:27:37 +0100 | [diff] [blame] | 456 | |
| 457 | subtest 'Check file structure with defined folder and filenames' => sub { |
| 458 | # Load example file |
| 459 | my $file = catfile($f, 'data', 'goe_sample.i5.xml'); |
| 460 | my $t = test_tei2korapxml( |
| 461 | tmp => 'script_out', |
| 462 | file => $file, |
| 463 | param => '-ti --base-foundry=root --data-file=primary --header-file=meta' |
| 464 | )->stderr_like(qr!tei2korapxml: .*? text_id=GOE_AGA\.00000!) |
| 465 | ->file_exists_not('GOE/AGA/00000/header.xml', 'Header not there') |
| 466 | ->file_exists_not('GOE/AGA/header.xml', 'Header not there') |
| 467 | ->file_exists_not('GOE/header.xml', 'Header not there') |
| 468 | ->file_exists_not('GOE/AGA/00000/data.xml', 'Data not there') |
| 469 | ->file_exists_not('GOE/AGA/00000/base/tokens_conservative.xml', 'Tokens not there') |
| 470 | ->file_exists_not('GOE/AGA/00000/base/tokens_aggressive.xml', 'Tokens not there') |
| 471 | ->file_exists('GOE/AGA/00000/meta.xml', 'Header there') |
| 472 | ->file_exists('GOE/AGA/meta.xml', 'Header there') |
| 473 | ->file_exists('GOE/meta.xml', 'Header there') |
| 474 | ->file_exists('GOE/AGA/00000/primary.xml', 'Data there') |
| 475 | ->file_exists('GOE/AGA/00000/root/tokens_conservative.xml', 'Tokens there') |
| 476 | ->file_exists('GOE/AGA/00000/root/tokens_aggressive.xml', 'Tokens there') |
| 477 | ; |
| 478 | |
| 479 | $t->unzip_xml('GOE/AGA/00000/primary.xml') |
| 480 | ->content_like(qr/\Q"Kriegstheater"\E/) |
| 481 | ; |
| 482 | }; |
| 483 | |
Akron | 1a5271a | 2021-02-18 13:18:15 +0100 | [diff] [blame] | 484 | subtest 'Check Inline annotations with defined foundry and folder' => sub { |
| 485 | # Load example file |
| 486 | my $file = catfile($f, 'data', 'goe_sample_tagged.i5.xml'); |
| 487 | |
| 488 | my $t = test_tei2korapxml( |
| 489 | file => $file, |
| 490 | env => 'KORAPXMLTEI_INLINE=1', |
| 491 | tmp => 'script_tagged', |
| 492 | param => '--inline-tokens=myfoundry#myfile' |
| 493 | ) |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 494 | ->stderr_like(qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!) |
Akron | 1a5271a | 2021-02-18 13:18:15 +0100 | [diff] [blame] | 495 | |
| 496 | ->file_exists_not('GOE/AGA/00000/tokens/morpho.xml', 'Morpho not generated') |
| 497 | |
| 498 | # Check zip using xml loy |
| 499 | ->unzip_xml('GOE/AGA/00000/myfoundry/myfile.xml') |
| 500 | |
| 501 | ->attr_is('layer', 'docid', 'GOE_AGA.00000') |
| 502 | ->attr_is('spanList span:nth-child(1)', 'id', 's0') |
| 503 | ->attr_is('spanList span:nth-child(1)', 'from', '75') |
| 504 | ->attr_is('spanList span:nth-child(1)', 'to', '81') |
| 505 | ->attr_is('spanList span:nth-child(1)', 'l', '7') |
| 506 | ; |
| 507 | |
| 508 | $t = test_tei2korapxml( |
| 509 | file => $file, |
| 510 | env => 'KORAPXMLTEI_INLINE=1', |
| 511 | tmp => 'script_tagged', |
| 512 | param => '--inline-tokens=myfoundry' |
| 513 | ) |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 514 | ->stderr_like(qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!) |
Akron | 1a5271a | 2021-02-18 13:18:15 +0100 | [diff] [blame] | 515 | |
| 516 | ->file_exists_not('GOE/AGA/00000/tokens/morpho.xml', 'Morpho not generated') |
| 517 | |
| 518 | # Check zip using xml loy |
| 519 | ->unzip_xml('GOE/AGA/00000/myfoundry/morpho.xml') |
| 520 | |
| 521 | ->attr_is('layer', 'docid', 'GOE_AGA.00000') |
| 522 | ->attr_is('spanList span:nth-child(1)', 'id', 's0') |
| 523 | ->attr_is('spanList span:nth-child(1)', 'from', '75') |
| 524 | ->attr_is('spanList span:nth-child(1)', 'to', '81') |
| 525 | ->attr_is('spanList span:nth-child(1)', 'l', '7') |
| 526 | ; |
| 527 | }; |
| 528 | |
Akron | 09e0b2c | 2020-07-28 15:57:01 +0200 | [diff] [blame] | 529 | subtest 'Check Inline annotations with untagged file' => sub { |
| 530 | |
| 531 | # Load example file |
| 532 | my $file = catfile($f, 'data', 'goe_sample.i5.xml'); |
| 533 | |
| 534 | my ($fh, $outzip) = korap_tempfile('script_untagged'); |
| 535 | |
| 536 | # Generate zip file (unportable!) |
| 537 | stderr_like( |
| 538 | sub { `cat '$file' | KORAPXMLTEI_INLINE=1 perl '$script' > '$outzip'` }, |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 539 | qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!, |
Akron | 09e0b2c | 2020-07-28 15:57:01 +0200 | [diff] [blame] | 540 | 'Processing 1' |
| 541 | ); |
| 542 | |
| 543 | # TODO: there should be a better way to test this |
| 544 | stderr_unlike( |
| 545 | sub { `cat '$file' | KORAPXMLTEI_INLINE=1 perl '$script' > '$outzip'` }, |
| 546 | qr!.*undefined value.*!, |
| 547 | 'Processing 2' |
| 548 | ); |
| 549 | # |
| 550 | |
| 551 | ok(-e $outzip, "File $outzip exists"); |
| 552 | |
| 553 | my $zip = IO::Uncompress::Unzip->new( |
| 554 | $outzip, |
| 555 | Name => 'GOE/AGA/00000/tokens/morpho.xml' |
| 556 | ); |
| 557 | ok((not $zip), 'missing morpho.xml'); |
| 558 | |
| 559 | $zip = IO::Uncompress::Unzip->new( |
| 560 | $outzip, |
| 561 | Name => 'GOE/AGA/00000/struct/structure.xml' |
| 562 | ); |
| 563 | ok($zip, 'found structure.xml'); |
| 564 | }; |
Akron | e68ec0c | 2020-07-28 18:06:19 +0200 | [diff] [blame] | 565 | |
Akron | 3378dfd | 2020-08-01 15:01:36 +0200 | [diff] [blame] | 566 | |
Akron | eaa9623 | 2020-10-15 17:06:15 +0200 | [diff] [blame] | 567 | subtest 'Check input encoding' => sub { |
| 568 | |
| 569 | # Load example file |
| 570 | test_tei2korapxml( |
| 571 | file => catfile($f, 'data', 'goe_sample.i5.xml'), |
| 572 | env => 'KORAPXMLTEI_INLINE=1', |
| 573 | tmp => 'script_utf8_enc' |
| 574 | ) |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 575 | ->stderr_like(qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!) |
Akron | eaa9623 | 2020-10-15 17:06:15 +0200 | [diff] [blame] | 576 | ->unzip_xml('GOE/AGA/00000/data.xml') |
| 577 | ->content_like(qr/\Q"Kriegstheater"\E/) |
| 578 | ->content_like(qr/\QTür'\E/) |
| 579 | ; |
| 580 | |
| 581 | test_tei2korapxml( |
| 582 | file => catfile($f, 'data', 'goe_sample.i5.iso.xml'), |
| 583 | env => 'KORAPXMLTEI_INLINE=1', |
| 584 | tmp => 'script_iso_enc' |
| 585 | ) |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 586 | ->stderr_like(qr!tei2korapxml:.*? text_id=GOE_AGA\.00000!) |
Akron | eaa9623 | 2020-10-15 17:06:15 +0200 | [diff] [blame] | 587 | ->unzip_xml('GOE/AGA/00000/data.xml') |
| 588 | ->content_like(qr/\Q"Kriegstheater"\E/) |
| 589 | ->content_like(qr/\QTür'\E/) |
| 590 | ; |
| 591 | }; |
| 592 | |
Marc Kupietz | 44b1f25 | 2020-11-26 16:31:40 +0100 | [diff] [blame] | 593 | subtest 'Check encoding with utf-8 sigle' => sub { |
| 594 | |
| 595 | # Load example file |
| 596 | my $file = catfile($f, 'data', 'wdd_sample.i5.xml'); |
| 597 | |
| 598 | my $t = test_tei2korapxml( |
| 599 | tmp => 'script_sigle', |
| 600 | file => $file, |
| 601 | param => "-ti" |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 602 | )->stderr_like(qr!tei2korapxml:.*? text_id=WDD19_ß0000\.10317!) |
Marc Kupietz | 44b1f25 | 2020-11-26 16:31:40 +0100 | [diff] [blame] | 603 | ->stderr_unlike(qr!Debugging is activated!); |
| 604 | |
| 605 | $t->unzip_xml('WDD19/ß0000/10317/header.xml') |
| 606 | ->text_is('idsHeader fileDesc titleStmt textSigle', 'WDD19/ß0000.10317'); |
| 607 | |
| 608 | $t->unzip_xml('WDD19/ß0000/10317/data.xml') |
| 609 | ->attr_is('raw_text', 'docid', 'WDD19_ß0000.10317'); |
| 610 | |
| 611 | $t->unzip_xml('WDD19/ß0000/10317/struct/structure.xml') |
| 612 | ->attr_is('layer', 'docid', 'WDD19_ß0000.10317'); |
| 613 | |
| 614 | $t->unzip_xml('WDD19/ß0000/10317/base/tokens_conservative.xml') |
| 615 | ->attr_is('layer', 'docid', 'WDD19_ß0000.10317'); |
| 616 | }; |
| 617 | |
Marc Kupietz | 8a954e5 | 2021-02-16 22:03:07 +0100 | [diff] [blame] | 618 | subtest 'Check entity replacement' => sub { |
| 619 | my $t = test_tei2korapxml( |
| 620 | file => catfile($f, 'data', 'text_with_entities.i5.xml'), |
| 621 | tmp => 'script_entity_replacement', |
| 622 | param => '-ti' |
Akron | 9157792 | 2021-02-19 10:32:54 +0100 | [diff] [blame^] | 623 | )->stderr_like(qr!tei2korapxml:.*? text_id=CORP_DOC.00003!); |
Marc Kupietz | 8a954e5 | 2021-02-16 22:03:07 +0100 | [diff] [blame] | 624 | |
| 625 | $t->unzip_xml('CORP/DOC/00003/data.xml') |
| 626 | ->content_like(qr!üüü Aα≈„▒░▓█╗┐┌╔═─┬╦┴╩╝┘└╚│║┼╬┤╣╠├•ˇčˆ†‡ě€ƒ…‗ıι“„▄‹‘‚—–νœŒωΩ‰φπϖř”ρ›’‘šŠσ□■▪⊂˜™▀ŸžŽ!); |
| 627 | |
| 628 | $t->unzip_xml('CORP/DOC/00003/header.xml') |
| 629 | ->content_like(qr!üüü x α•α y!); |
| 630 | }; |
| 631 | |
Akron | 3378dfd | 2020-08-01 15:01:36 +0200 | [diff] [blame] | 632 | subtest 'Test Log' => sub { |
| 633 | test_tei2korapxml( |
| 634 | tmp => 'script_out', |
| 635 | file => $file, |
| 636 | param => '-l=warn' |
| 637 | )->stderr_is(''); |
| 638 | }; |
| 639 | |
| 640 | |
Akron | 797e807 | 2020-02-13 07:59:40 +0100 | [diff] [blame] | 641 | done_testing; |