Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
| 4 | use Data::Dumper; |
| 5 | use JSON::XS; |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 6 | |
Akron | fab17d3 | 2020-07-31 14:38:29 +0200 | [diff] [blame] | 7 | if ($ENV{SKIP_REAL}) { |
| 8 | plan skip_all => 'Skip real tests'; |
| 9 | }; |
| 10 | |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 11 | use utf8; |
| 12 | use lib 'lib', '../lib'; |
| 13 | |
| 14 | use File::Basename 'dirname'; |
| 15 | use File::Spec::Functions 'catdir'; |
| 16 | |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 17 | use_ok('KorAP::XML::Krill'); |
| 18 | |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 19 | my $path = catdir(dirname(__FILE__), 'corpus','REDEW','DOC1','00000'); |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 20 | |
| 21 | ok(my $doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 22 | ok($doc->parse, 'Parse document'); |
| 23 | |
| 24 | is($doc->text_sigle, 'REDEW/DOC1/00000', 'Correct text sigle'); |
| 25 | is($doc->doc_sigle, 'REDEW/DOC1', 'Correct document sigle'); |
| 26 | is($doc->corpus_sigle, 'REDEW', 'Correct corpus sigle'); |
| 27 | |
| 28 | my $meta = $doc->meta; |
Marc Kupietz | 400590b | 2022-12-23 16:02:36 +0100 | [diff] [blame^] | 29 | is($meta->{T_title}, 'Gram', 'Title'); # ??? |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 30 | ok(!$meta->{T_sub_title}, 'SubTitle'); |
| 31 | ok(!$meta->{T_author}, 'Author'); |
| 32 | ok(!$meta->{A_editor}, 'Editor'); |
| 33 | ok(!$meta->{S_pub_place}, 'PubPlace'); |
Akron | 8ff5879 | 2020-04-17 16:51:55 +0200 | [diff] [blame] | 34 | ok(!$meta->{A_publisher}, 'Publisher'); |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 35 | |
| 36 | is($meta->{S_text_type}, '?', 'Text Type'); # ??? |
| 37 | ok(!$meta->{S_text_type_art}, 'No Text Type Art'); |
| 38 | ok(!$meta->{S_text_type_ref}, 'No Text Type Ref'); |
| 39 | ok(!$meta->{S_text_domain}, 'No Text Domain'); |
| 40 | ok(!$meta->{S_text_column}, 'No Text Column'); |
| 41 | |
| 42 | ok(!$meta->{K_text_class}->[0], 'Correct Text Class'); |
| 43 | |
Akron | 8ff5879 | 2020-04-17 16:51:55 +0200 | [diff] [blame] | 44 | is($meta->{D_pub_date}, '00000000', 'Creation date'); # ??? |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 45 | is($meta->{D_creation_date}, '20200000', 'Creation date'); |
| 46 | is($meta->{S_availability}, 'QAO-NC', 'License'); # ??? |
| 47 | ok(!$meta->{A_pages}, 'Pages'); |
| 48 | |
| 49 | ok(!$meta->{A_file_edition_statement}, 'File Statement'); |
| 50 | ok(!$meta->{A_bibl_edition_statement}, 'Bibl Statement'); |
| 51 | |
| 52 | ok(!$meta->{A_reference}, 'Reference'); |
| 53 | ok(!$meta->{S_language}, 'Language'); # ??? |
| 54 | |
| 55 | is($meta->{T_corpus_title}, 'Redewiedergabe', 'Correct Corpus title'); |
| 56 | ok(!$meta->{T_corpus_sub_title}, 'Correct Corpus sub title'); |
Akron | 8ff5879 | 2020-04-17 16:51:55 +0200 | [diff] [blame] | 57 | ok(!$meta->{T_corpus_author}, 'Correct Corpus author'); |
| 58 | ok(!$meta->{A_corpus_editor}, 'Correct Corpus editor'); |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 59 | |
| 60 | is($meta->{T_doc_title}, 'Redewiedergabe Dokument 1', 'Correct Doc title'); |
| 61 | ok(!$meta->{T_doc_sub_title}, 'Correct Doc sub title'); |
| 62 | ok(!$meta->{T_doc_author}, 'Correct Doc author'); |
| 63 | ok(!$meta->{A_doc_editor}, 'Correct doc editor'); |
| 64 | |
| 65 | # Tokenization |
| 66 | use_ok('KorAP::XML::Tokenizer'); |
| 67 | |
| 68 | my ($token_base_foundry, $token_base_layer) = (qw/drukola Morpho/); |
| 69 | |
| 70 | # Get tokenization |
| 71 | my $tokens = KorAP::XML::Tokenizer->new( |
| 72 | path => $doc->path, |
| 73 | doc => $doc, |
| 74 | foundry => $token_base_foundry, |
| 75 | layer => $token_base_layer, |
| 76 | name => 'tokens' |
| 77 | ); |
| 78 | |
| 79 | ok($tokens, 'Token Object is fine'); |
| 80 | ok($tokens->parse, 'Token parsing is fine'); |
| 81 | |
| 82 | my $output = decode_json( $tokens->to_json ); |
| 83 | |
| 84 | is(substr($output->{data}->{text}, 0, 100), 'Cechov,_Anton_Pavlovic_Gram.tg4_1.xml 1886 1880 Gram Čechov, Anton Pavlovič yes yes Erzähltext digbi', 'Primary Data'); |
| 85 | |
| 86 | is($output->{data}->{name}, 'tokens', 'tokenName'); |
| 87 | is($output->{data}->{tokenSource}, 'drukola#morpho', 'tokenSource'); |
| 88 | is($output->{version}, '0.03', 'version'); |
| 89 | |
| 90 | is($output->{data}->{foundries}, '', 'Foundries'); |
| 91 | is($output->{data}->{layerInfos}, '', 'layerInfos'); |
| 92 | is($output->{data}->{stream}->[0]->[4], 's:Hörst', 'data'); |
| 93 | |
| 94 | is($output->{textSigle}, 'REDEW/DOC1/00000', 'Correct text sigle'); |
| 95 | is($output->{docSigle}, 'REDEW/DOC1', 'Correct document sigle'); |
| 96 | is($output->{corpusSigle}, 'REDEW', 'Correct corpus sigle'); |
| 97 | |
Marc Kupietz | 400590b | 2022-12-23 16:02:36 +0100 | [diff] [blame^] | 98 | is($output->{title}, 'Gram', 'Title'); |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 99 | ok(!$output->{subTitle}, 'Correct SubTitle'); |
| 100 | ok(!$output->{author}, 'Author'); |
| 101 | ok(!exists $output->{editor}, 'Publisher'); |
| 102 | |
| 103 | # Add annotations |
| 104 | $tokens->add('DRuKoLa', 'Morpho'); |
| 105 | $tokens->add('DeReKo', 'Structure'); |
| 106 | |
| 107 | $output = decode_json( $tokens->to_json ); |
| 108 | |
| 109 | my $first = $output->{data}->{stream}->[0]; |
| 110 | |
| 111 | is('-:tokens$<i>13',$first->[0]); |
Akron | dec4312 | 2020-03-03 11:22:25 +0100 | [diff] [blame] | 112 | is('<>:base/s:t$<b>64<i>0<i>197<i>13<b>0',$first->[1]); |
| 113 | is('<>:dereko/s:text$<b>64<i>0<i>197<i>13<b>0',$first->[2]); |
| 114 | is('<>:dereko/s:body$<b>64<i>118<i>197<i>13<b>1',$first->[3]); |
| 115 | is('<>:dereko/s:p$<b>64<i>118<i>197<i>13<b>2',$first->[4]); |
| 116 | is('<>:dereko/s:said$<b>64<i>118<i>197<i>13<b>3<s>1',$first->[5]); |
| 117 | is('@:dereko/s:level:1$<b>17<s>1<i>13',$first->[6]); |
| 118 | is('@:dereko/s:content:speech$<b>17<s>1<i>13',$first->[7]); |
| 119 | is('@:dereko/s:mode:direct$<b>17<s>1<i>13',$first->[8]); |
| 120 | is('@:dereko/s:id:1$<b>17<s>1<i>13',$first->[9]); |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 121 | is('_0$<i>123<i>128',$first->[10]); |
| 122 | is("drukola/l:H\x{f6}rst",$first->[11]); |
| 123 | is('drukola/m:msd:rfpos',$first->[12]); |
| 124 | is('drukola/m:sentstart:no',$first->[13]); |
| 125 | is('drukola/m:stwr:direct.speech.1',$first->[14]); |
| 126 | is('drukola/p:VVFIN',$first->[15]); |
| 127 | is("i:h\x{f6}rst",$first->[16]); |
| 128 | is("s:H\x{f6}rst",$first->[17]); |
| 129 | |
| 130 | my $nine = join(',', @{$output->{data}->{stream}->[9]}); |
| 131 | like($nine, qr{drukola\/l:nichts}, 'Nichts'); |
| 132 | like($nine, qr{_9\$<i>170<i>176}, 'Term boundaries'); |
Akron | dec4312 | 2020-03-03 11:22:25 +0100 | [diff] [blame] | 133 | unlike($nine, qr{<>:dereko/s:said\$<b>64<i>176<i>196<i>13<b>4<s>1}, 'Term boundaries'); |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 134 | |
| 135 | my $ten = join(',', @{$output->{data}->{stream}->[10]}); |
| 136 | like($ten, qr{_10\$<i>177<i>180}, 'Term boundaries'); |
Akron | dec4312 | 2020-03-03 11:22:25 +0100 | [diff] [blame] | 137 | like($ten, qr{<>:dereko/s:said\$<b>64<i>176<i>196<i>13<b>4<s>1}, 'Term boundaries'); |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 138 | |
| 139 | my $eleven = join(',', @{$output->{data}->{stream}->[11]}); |
| 140 | like($eleven, qr{_11\$<i>181<i>188}, 'Term boundaries'); |
| 141 | like($eleven, qr{<>:dereko/s:seg\$<b>64<i>180<i>188<i>12<b>5<s>1}, 'Segment'); |
| 142 | |
| 143 | |
| 144 | my $twelve = join(',', @{$output->{data}->{stream}->[12]}); |
| 145 | like($twelve, qr{_12\$<i>189<i>195}, 'Term boundaries'); |
| 146 | like($twelve, qr{drukola/l:Wort}, 'Lemma'); |
| 147 | like($twelve, qr{<>:dereko/s:seg\$<b>64<i>188<i>195<i>13<b>5<s>1}, 'Segment'); |
| 148 | |
Akron | 8ff5879 | 2020-04-17 16:51:55 +0200 | [diff] [blame] | 149 | |
| 150 | # Updated format: |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 151 | $path = catdir(dirname(__FILE__), 'corpus','REDEW','DOC1b','00011'); |
Akron | 8ff5879 | 2020-04-17 16:51:55 +0200 | [diff] [blame] | 152 | |
| 153 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 154 | ok($doc->parse, 'Parse document'); |
| 155 | |
| 156 | is($doc->text_sigle, 'REDEW/DOC1/00011', 'Correct text sigle'); |
| 157 | is($doc->doc_sigle, 'REDEW/DOC1', 'Correct document sigle'); |
| 158 | is($doc->corpus_sigle, 'REDEW', 'Correct corpus sigle'); |
| 159 | |
| 160 | $meta = $doc->meta; |
| 161 | |
| 162 | is($meta->{A_distributor}, 'Institut für Deutsche Sprache', 'Distributor'); |
| 163 | is($meta->{D_pub_date}, '18730000', 'Publication date'); |
| 164 | is($meta->{D_creation_date}, '18730000', 'Publication date'); |
| 165 | is($meta->{S_pub_place_key}, 'DE', 'Publication place key'); |
| 166 | is($meta->{T_corpus_title}, 'Redewiedergabe', 'Title'); |
| 167 | is($meta->{T_doc_title}, 'Redewiedergabe Dokument 1', 'Title'); |
| 168 | is($meta->{T_author}, 'Christen, Ada', 'Author'); |
| 169 | is($meta->{T_title}, 'Rahel', 'Author'); |
| 170 | is($meta->{S_availability}, 'QAO-NC-LOC:ids', 'Availability'); |
| 171 | is($meta->{S_text_type_art}, 'Erzähltext', 'Availability'); |
| 172 | |
| 173 | # Tokenization |
| 174 | use_ok('KorAP::XML::Tokenizer'); |
| 175 | |
| 176 | ($token_base_foundry, $token_base_layer) = (qw/rwk Morpho/); |
| 177 | |
| 178 | # Get tokenization |
| 179 | $tokens = KorAP::XML::Tokenizer->new( |
| 180 | path => $doc->path, |
| 181 | doc => $doc, |
| 182 | foundry => $token_base_foundry, |
| 183 | layer => $token_base_layer, |
| 184 | name => 'tokens' |
| 185 | ); |
| 186 | |
| 187 | ok($tokens, 'Token Object is fine'); |
| 188 | ok($tokens->parse, 'Token parsing is fine'); |
| 189 | |
| 190 | $output = decode_json( $tokens->to_json ); |
| 191 | |
| 192 | is(substr($output->{data}->{text}, 0, 100), 'Er hatte den Kopf weit nach rückwärts gebeugt, seine langen schwarzen Haare lockten sich über den li', 'Primary Data'); |
| 193 | |
| 194 | # Add annotations |
Akron | 28299f4 | 2020-04-17 17:54:33 +0200 | [diff] [blame] | 195 | ok($tokens->add('RWK', 'Morpho')); |
| 196 | ok($tokens->add('RWK', 'Structure')); |
Akron | 8ff5879 | 2020-04-17 16:51:55 +0200 | [diff] [blame] | 197 | |
| 198 | $output = decode_json( $tokens->to_json ); |
| 199 | |
| 200 | $first = $output->{data}->{stream}->[0]; |
| 201 | |
Akron | 56deacb | 2020-08-10 10:03:55 +0200 | [diff] [blame] | 202 | is('-:base/paragraphs$<i>1',$first->[0]); |
Akron | 28299f4 | 2020-04-17 17:54:33 +0200 | [diff] [blame] | 203 | is('-:base/sentences$<i>21',$first->[1]); |
| 204 | is('-:tokens$<i>522',$first->[2]); |
Akron | 56deacb | 2020-08-10 10:03:55 +0200 | [diff] [blame] | 205 | |
Akron | 28299f4 | 2020-04-17 17:54:33 +0200 | [diff] [blame] | 206 | is('<>:base/s:s$<b>64<i>0<i>139<i>23<b>1',$first->[3]); |
| 207 | is('<>:base/s:p$<b>64<i>0<i>2631<i>449<b>1',$first->[4]); |
| 208 | is('<>:base/s:t$<b>64<i>0<i>3062<i>522<b>0',$first->[5]); |
| 209 | is('_0$<i>0<i>2',$first->[6]); |
| 210 | is('i:er',$first->[7]); |
| 211 | is('rwk/l:er',$first->[8]); |
Akron | c403644 | 2020-04-21 18:41:41 +0200 | [diff] [blame] | 212 | is('rwk/m:bc:PRO',$first->[9]); |
| 213 | is('rwk/m:case:Nom',$first->[10]); |
| 214 | is('rwk/m:gender:Masc',$first->[11]); |
| 215 | is('rwk/m:number:Sg',$first->[12]); |
| 216 | is('rwk/m:person:3',$first->[13]); |
| 217 | is('rwk/m:type:Pers',$first->[14]); |
| 218 | is('rwk/m:usage:Subst',$first->[15]); |
| 219 | is('rwk/norm:Er',$first->[16]); |
| 220 | is('rwk/p:PPER',$first->[17]); |
| 221 | is('s:Er',$first->[18]); |
Akron | 8ff5879 | 2020-04-17 16:51:55 +0200 | [diff] [blame] | 222 | |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 223 | |
| 224 | |
| 225 | |
| 226 | # Updated format: |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 227 | $path = catdir(dirname(__FILE__), 'corpus','REDEW','DOC1b','00011'); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 228 | |
| 229 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 230 | ok($doc->parse, 'Parse document'); |
| 231 | |
| 232 | is($doc->text_sigle, 'REDEW/DOC1/00011', 'Correct text sigle'); |
| 233 | is($doc->doc_sigle, 'REDEW/DOC1', 'Correct document sigle'); |
| 234 | is($doc->corpus_sigle, 'REDEW', 'Correct corpus sigle'); |
| 235 | |
| 236 | $meta = $doc->meta; |
| 237 | |
| 238 | is($meta->{A_distributor}, 'Institut für Deutsche Sprache', 'Distributor'); |
| 239 | is($meta->{D_pub_date}, '18730000', 'Publication date'); |
| 240 | is($meta->{D_creation_date}, '18730000', 'Publication date'); |
| 241 | is($meta->{S_pub_place_key}, 'DE', 'Publication place key'); |
| 242 | is($meta->{T_corpus_title}, 'Redewiedergabe', 'Title'); |
| 243 | is($meta->{T_doc_title}, 'Redewiedergabe Dokument 1', 'Title'); |
| 244 | is($meta->{T_author}, 'Christen, Ada', 'Author'); |
| 245 | is($meta->{T_title}, 'Rahel', 'Author'); |
| 246 | is($meta->{S_availability}, 'QAO-NC-LOC:ids', 'Availability'); |
| 247 | is($meta->{S_text_type_art}, 'Erzähltext', 'Availability'); |
| 248 | |
| 249 | # Tokenization |
| 250 | use_ok('KorAP::XML::Tokenizer'); |
| 251 | |
| 252 | ($token_base_foundry, $token_base_layer) = (qw/rwk Morpho/); |
| 253 | |
| 254 | # Get tokenization |
| 255 | $tokens = KorAP::XML::Tokenizer->new( |
| 256 | path => $doc->path, |
| 257 | doc => $doc, |
| 258 | foundry => $token_base_foundry, |
| 259 | layer => $token_base_layer, |
| 260 | name => 'tokens' |
| 261 | ); |
| 262 | |
| 263 | ok($tokens, 'Token Object is fine'); |
| 264 | ok($tokens->parse, 'Token parsing is fine'); |
| 265 | |
| 266 | $output = decode_json( $tokens->to_json ); |
| 267 | |
| 268 | is(substr($output->{data}->{text}, 0, 100), 'Er hatte den Kopf weit nach rückwärts gebeugt, seine langen schwarzen Haare lockten sich über den li', 'Primary Data'); |
| 269 | |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 270 | # Add annotations |
| 271 | ok($tokens->add('RWK', 'Morpho')); |
| 272 | ok($tokens->add('RWK', 'Structure')); |
| 273 | |
| 274 | $output = decode_json( $tokens->to_json ); |
| 275 | |
| 276 | $first = $output->{data}->{stream}->[0]; |
| 277 | |
Akron | 56deacb | 2020-08-10 10:03:55 +0200 | [diff] [blame] | 278 | is('-:base/paragraphs$<i>1',$first->[0]); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 279 | is('-:base/sentences$<i>21',$first->[1]); |
| 280 | is('-:tokens$<i>522',$first->[2]); |
| 281 | is('<>:base/s:s$<b>64<i>0<i>139<i>23<b>1',$first->[3]); |
| 282 | is('<>:base/s:p$<b>64<i>0<i>2631<i>449<b>1',$first->[4]); |
| 283 | is('<>:base/s:t$<b>64<i>0<i>3062<i>522<b>0',$first->[5]); |
| 284 | is('_0$<i>0<i>2',$first->[6]); |
| 285 | is('i:er',$first->[7]); |
| 286 | is('rwk/l:er',$first->[8]); |
| 287 | is('rwk/m:bc:PRO',$first->[9]); |
| 288 | is('rwk/m:case:Nom',$first->[10]); |
| 289 | is('rwk/m:gender:Masc',$first->[11]); |
| 290 | is('rwk/m:number:Sg',$first->[12]); |
| 291 | is('rwk/m:person:3',$first->[13]); |
| 292 | is('rwk/m:type:Pers',$first->[14]); |
| 293 | is('rwk/m:usage:Subst',$first->[15]); |
| 294 | is('rwk/norm:Er',$first->[16]); |
| 295 | is('rwk/p:PPER',$first->[17]); |
| 296 | is('s:Er',$first->[18]); |
| 297 | |
| 298 | |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 299 | $path = catdir(dirname(__FILE__), 'corpus','REDEW','DOC1b','00001'); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 300 | |
| 301 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 302 | ok($doc->parse, 'Parse document'); |
| 303 | |
| 304 | is($doc->text_sigle, 'REDEW/DOC1/00001', 'Correct text sigle'); |
| 305 | is($doc->doc_sigle, 'REDEW/DOC1', 'Correct document sigle'); |
| 306 | is($doc->corpus_sigle, 'REDEW', 'Correct corpus sigle'); |
| 307 | |
| 308 | $meta = $doc->meta; |
| 309 | |
| 310 | is($meta->{A_distributor}, 'Institut für Deutsche Sprache', 'Distributor'); |
| 311 | is($meta->{D_pub_date}, '18950000', 'Publication date'); |
| 312 | is($meta->{D_creation_date}, '18950000', 'Publication date'); |
| 313 | is($meta->{S_pub_place_key}, 'DE', 'Publication place key'); |
| 314 | is($meta->{T_corpus_title}, 'Redewiedergabe', 'Title'); |
| 315 | is($meta->{T_doc_title}, 'Redewiedergabe Dokument 1', 'Title'); |
| 316 | is($meta->{T_author}, 'Busch, Wilhelm', 'Author'); |
| 317 | is($meta->{T_title}, 'Der Schmetterling', 'Titel'); |
| 318 | is($meta->{S_availability}, 'QAO-NC-LOC:ids', 'Availability'); |
| 319 | is($meta->{S_text_type_art}, 'Erzähltext', 'Availability'); |
| 320 | |
| 321 | # Tokenization |
| 322 | use_ok('KorAP::XML::Tokenizer'); |
| 323 | |
| 324 | ($token_base_foundry, $token_base_layer) = (qw/rwk Morpho/); |
| 325 | |
| 326 | # Get tokenization |
| 327 | $tokens = KorAP::XML::Tokenizer->new( |
| 328 | path => $doc->path, |
| 329 | doc => $doc, |
| 330 | foundry => $token_base_foundry, |
| 331 | layer => $token_base_layer, |
| 332 | name => 'tokens' |
| 333 | ); |
| 334 | |
| 335 | ok($tokens, 'Token Object is fine'); |
| 336 | ok($tokens->parse, 'Token parsing is fine'); |
| 337 | |
| 338 | $output = decode_json( $tokens->to_json ); |
| 339 | |
| 340 | is(substr($output->{data}->{text}, 0, 100), 'Eier! Schinken! Franzwein! Flink, marsch!« schrie ihn gebieterisch der Nazi an und kniff dabei einen', 'Primary Data'); |
| 341 | |
| 342 | # Add annotations |
| 343 | ok($tokens->add('RWK', 'Morpho')); |
| 344 | ok($tokens->add('RWK', 'Structure')); |
| 345 | |
| 346 | $output = decode_json( $tokens->to_json ); |
| 347 | |
| 348 | $first = $output->{data}->{stream}->[0]; |
| 349 | |
Akron | 56deacb | 2020-08-10 10:03:55 +0200 | [diff] [blame] | 350 | is('-:base/paragraphs$<i>1',$first->[0]); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 351 | is('-:base/sentences$<i>33',$first->[1]); |
| 352 | is('-:tokens$<i>511',$first->[2]); |
| 353 | is('<>:base/s:s$<b>64<i>0<i>6<i>2<b>1',$first->[3]); |
| 354 | is('<>:base/s:p$<b>64<i>0<i>2010<i>307<b>1',$first->[4]); |
| 355 | is('<>:base/s:t$<b>64<i>0<i>3246<i>511<b>0',$first->[5]); |
| 356 | |
| 357 | |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 358 | $path = catdir(dirname(__FILE__), 'corpus','REDEW','DOC1b','00558'); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 359 | |
| 360 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 361 | ok($doc->parse, 'Parse document'); |
| 362 | |
| 363 | is($doc->text_sigle, 'REDEW/DOC1/00558', 'Correct text sigle'); |
| 364 | is($doc->doc_sigle, 'REDEW/DOC1', 'Correct document sigle'); |
| 365 | is($doc->corpus_sigle, 'REDEW', 'Correct corpus sigle'); |
| 366 | |
| 367 | $meta = $doc->meta; |
| 368 | |
| 369 | # Tokenization |
| 370 | use_ok('KorAP::XML::Tokenizer'); |
| 371 | |
| 372 | ($token_base_foundry, $token_base_layer) = (qw/rwk Morpho/); |
| 373 | |
| 374 | # Get tokenization |
| 375 | $tokens = KorAP::XML::Tokenizer->new( |
| 376 | path => $doc->path, |
| 377 | doc => $doc, |
| 378 | foundry => $token_base_foundry, |
| 379 | layer => $token_base_layer, |
| 380 | name => 'tokens' |
| 381 | ); |
| 382 | |
| 383 | ok($tokens, 'Token Object is fine'); |
| 384 | ok($tokens->parse, 'Token parsing is fine'); |
| 385 | |
| 386 | $output = decode_json( $tokens->to_json ); |
| 387 | |
| 388 | is(substr($output->{data}->{text}, 0, 100), 'Außer den sechs größten Vereinigungen haben sich 59 keiner Körperschaft angehörige Künstler angemeld', 'Primary Data'); |
| 389 | |
| 390 | # Add annotations |
| 391 | ok($tokens->add('RWK', 'Morpho')); |
| 392 | ok($tokens->add('RWK', 'Structure')); |
| 393 | |
| 394 | $output = decode_json( $tokens->to_json ); |
| 395 | |
| 396 | $first = $output->{data}->{stream}->[0]; |
| 397 | |
Akron | 56deacb | 2020-08-10 10:03:55 +0200 | [diff] [blame] | 398 | is('-:base/paragraphs$<i>1',$first->[0]); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 399 | is('-:base/sentences$<i>68',$first->[1]); |
| 400 | |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 401 | done_testing; |