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