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 | 56deacb | 2020-08-10 10:03:55 +0200 | [diff] [blame^] | 221 | is('-:base/paragraphs$<i>1',$first->[0]); |
Akron | 28299f4 | 2020-04-17 17:54:33 +0200 | [diff] [blame] | 222 | is('-:base/sentences$<i>21',$first->[1]); |
| 223 | is('-:tokens$<i>522',$first->[2]); |
Akron | 56deacb | 2020-08-10 10:03:55 +0200 | [diff] [blame^] | 224 | |
Akron | 28299f4 | 2020-04-17 17:54:33 +0200 | [diff] [blame] | 225 | is('<>:base/s:s$<b>64<i>0<i>139<i>23<b>1',$first->[3]); |
| 226 | is('<>:base/s:p$<b>64<i>0<i>2631<i>449<b>1',$first->[4]); |
| 227 | is('<>:base/s:t$<b>64<i>0<i>3062<i>522<b>0',$first->[5]); |
| 228 | is('_0$<i>0<i>2',$first->[6]); |
| 229 | is('i:er',$first->[7]); |
| 230 | is('rwk/l:er',$first->[8]); |
Akron | c403644 | 2020-04-21 18:41:41 +0200 | [diff] [blame] | 231 | is('rwk/m:bc:PRO',$first->[9]); |
| 232 | is('rwk/m:case:Nom',$first->[10]); |
| 233 | is('rwk/m:gender:Masc',$first->[11]); |
| 234 | is('rwk/m:number:Sg',$first->[12]); |
| 235 | is('rwk/m:person:3',$first->[13]); |
| 236 | is('rwk/m:type:Pers',$first->[14]); |
| 237 | is('rwk/m:usage:Subst',$first->[15]); |
| 238 | is('rwk/norm:Er',$first->[16]); |
| 239 | is('rwk/p:PPER',$first->[17]); |
| 240 | is('s:Er',$first->[18]); |
Akron | 8ff5879 | 2020-04-17 16:51:55 +0200 | [diff] [blame] | 241 | |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 242 | |
| 243 | |
| 244 | |
| 245 | # Updated format: |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 246 | $path = catdir(dirname(__FILE__), 'corpus','REDEW','DOC1b','00011'); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 247 | |
| 248 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 249 | ok($doc->parse, 'Parse document'); |
| 250 | |
| 251 | is($doc->text_sigle, 'REDEW/DOC1/00011', 'Correct text sigle'); |
| 252 | is($doc->doc_sigle, 'REDEW/DOC1', 'Correct document sigle'); |
| 253 | is($doc->corpus_sigle, 'REDEW', 'Correct corpus sigle'); |
| 254 | |
| 255 | $meta = $doc->meta; |
| 256 | |
| 257 | is($meta->{A_distributor}, 'Institut für Deutsche Sprache', 'Distributor'); |
| 258 | is($meta->{D_pub_date}, '18730000', 'Publication date'); |
| 259 | is($meta->{D_creation_date}, '18730000', 'Publication date'); |
| 260 | is($meta->{S_pub_place_key}, 'DE', 'Publication place key'); |
| 261 | is($meta->{T_corpus_title}, 'Redewiedergabe', 'Title'); |
| 262 | is($meta->{T_doc_title}, 'Redewiedergabe Dokument 1', 'Title'); |
| 263 | is($meta->{T_author}, 'Christen, Ada', 'Author'); |
| 264 | is($meta->{T_title}, 'Rahel', 'Author'); |
| 265 | is($meta->{S_availability}, 'QAO-NC-LOC:ids', 'Availability'); |
| 266 | is($meta->{S_text_type_art}, 'Erzähltext', 'Availability'); |
| 267 | |
| 268 | # Tokenization |
| 269 | use_ok('KorAP::XML::Tokenizer'); |
| 270 | |
| 271 | ($token_base_foundry, $token_base_layer) = (qw/rwk Morpho/); |
| 272 | |
| 273 | # Get tokenization |
| 274 | $tokens = KorAP::XML::Tokenizer->new( |
| 275 | path => $doc->path, |
| 276 | doc => $doc, |
| 277 | foundry => $token_base_foundry, |
| 278 | layer => $token_base_layer, |
| 279 | name => 'tokens' |
| 280 | ); |
| 281 | |
| 282 | ok($tokens, 'Token Object is fine'); |
| 283 | ok($tokens->parse, 'Token parsing is fine'); |
| 284 | |
| 285 | $output = decode_json( $tokens->to_json ); |
| 286 | |
| 287 | 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'); |
| 288 | |
| 289 | use Log::Log4perl; |
| 290 | |
| 291 | Log::Log4perl->init({ |
| 292 | 'log4perl.rootLogger' => 'WARN, STDERR', |
| 293 | 'log4perl.appender.STDERR' => 'Log::Log4perl::Appender::ScreenColoredLevels', |
| 294 | 'log4perl.appender.STDERR.layout' => 'PatternLayout', |
| 295 | 'log4perl.appender.STDERR.layout.ConversionPattern' => '[%r] %F %L %c - %m%n' |
| 296 | }); |
| 297 | |
| 298 | |
| 299 | # Add annotations |
| 300 | ok($tokens->add('RWK', 'Morpho')); |
| 301 | ok($tokens->add('RWK', 'Structure')); |
| 302 | |
| 303 | $output = decode_json( $tokens->to_json ); |
| 304 | |
| 305 | $first = $output->{data}->{stream}->[0]; |
| 306 | |
Akron | 56deacb | 2020-08-10 10:03:55 +0200 | [diff] [blame^] | 307 | is('-:base/paragraphs$<i>1',$first->[0]); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 308 | is('-:base/sentences$<i>21',$first->[1]); |
| 309 | is('-:tokens$<i>522',$first->[2]); |
| 310 | is('<>:base/s:s$<b>64<i>0<i>139<i>23<b>1',$first->[3]); |
| 311 | is('<>:base/s:p$<b>64<i>0<i>2631<i>449<b>1',$first->[4]); |
| 312 | is('<>:base/s:t$<b>64<i>0<i>3062<i>522<b>0',$first->[5]); |
| 313 | is('_0$<i>0<i>2',$first->[6]); |
| 314 | is('i:er',$first->[7]); |
| 315 | is('rwk/l:er',$first->[8]); |
| 316 | is('rwk/m:bc:PRO',$first->[9]); |
| 317 | is('rwk/m:case:Nom',$first->[10]); |
| 318 | is('rwk/m:gender:Masc',$first->[11]); |
| 319 | is('rwk/m:number:Sg',$first->[12]); |
| 320 | is('rwk/m:person:3',$first->[13]); |
| 321 | is('rwk/m:type:Pers',$first->[14]); |
| 322 | is('rwk/m:usage:Subst',$first->[15]); |
| 323 | is('rwk/norm:Er',$first->[16]); |
| 324 | is('rwk/p:PPER',$first->[17]); |
| 325 | is('s:Er',$first->[18]); |
| 326 | |
| 327 | |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 328 | $path = catdir(dirname(__FILE__), 'corpus','REDEW','DOC1b','00001'); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 329 | |
| 330 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 331 | ok($doc->parse, 'Parse document'); |
| 332 | |
| 333 | is($doc->text_sigle, 'REDEW/DOC1/00001', 'Correct text sigle'); |
| 334 | is($doc->doc_sigle, 'REDEW/DOC1', 'Correct document sigle'); |
| 335 | is($doc->corpus_sigle, 'REDEW', 'Correct corpus sigle'); |
| 336 | |
| 337 | $meta = $doc->meta; |
| 338 | |
| 339 | is($meta->{A_distributor}, 'Institut für Deutsche Sprache', 'Distributor'); |
| 340 | is($meta->{D_pub_date}, '18950000', 'Publication date'); |
| 341 | is($meta->{D_creation_date}, '18950000', 'Publication date'); |
| 342 | is($meta->{S_pub_place_key}, 'DE', 'Publication place key'); |
| 343 | is($meta->{T_corpus_title}, 'Redewiedergabe', 'Title'); |
| 344 | is($meta->{T_doc_title}, 'Redewiedergabe Dokument 1', 'Title'); |
| 345 | is($meta->{T_author}, 'Busch, Wilhelm', 'Author'); |
| 346 | is($meta->{T_title}, 'Der Schmetterling', 'Titel'); |
| 347 | is($meta->{S_availability}, 'QAO-NC-LOC:ids', 'Availability'); |
| 348 | is($meta->{S_text_type_art}, 'Erzähltext', 'Availability'); |
| 349 | |
| 350 | # Tokenization |
| 351 | use_ok('KorAP::XML::Tokenizer'); |
| 352 | |
| 353 | ($token_base_foundry, $token_base_layer) = (qw/rwk Morpho/); |
| 354 | |
| 355 | # Get tokenization |
| 356 | $tokens = KorAP::XML::Tokenizer->new( |
| 357 | path => $doc->path, |
| 358 | doc => $doc, |
| 359 | foundry => $token_base_foundry, |
| 360 | layer => $token_base_layer, |
| 361 | name => 'tokens' |
| 362 | ); |
| 363 | |
| 364 | ok($tokens, 'Token Object is fine'); |
| 365 | ok($tokens->parse, 'Token parsing is fine'); |
| 366 | |
| 367 | $output = decode_json( $tokens->to_json ); |
| 368 | |
| 369 | is(substr($output->{data}->{text}, 0, 100), 'Eier! Schinken! Franzwein! Flink, marsch!« schrie ihn gebieterisch der Nazi an und kniff dabei einen', 'Primary Data'); |
| 370 | |
| 371 | # Add annotations |
| 372 | ok($tokens->add('RWK', 'Morpho')); |
| 373 | ok($tokens->add('RWK', 'Structure')); |
| 374 | |
| 375 | $output = decode_json( $tokens->to_json ); |
| 376 | |
| 377 | $first = $output->{data}->{stream}->[0]; |
| 378 | |
Akron | 56deacb | 2020-08-10 10:03:55 +0200 | [diff] [blame^] | 379 | is('-:base/paragraphs$<i>1',$first->[0]); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 380 | is('-:base/sentences$<i>33',$first->[1]); |
| 381 | is('-:tokens$<i>511',$first->[2]); |
| 382 | is('<>:base/s:s$<b>64<i>0<i>6<i>2<b>1',$first->[3]); |
| 383 | is('<>:base/s:p$<b>64<i>0<i>2010<i>307<b>1',$first->[4]); |
| 384 | is('<>:base/s:t$<b>64<i>0<i>3246<i>511<b>0',$first->[5]); |
| 385 | |
| 386 | |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 387 | $path = catdir(dirname(__FILE__), 'corpus','REDEW','DOC1b','00558'); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 388 | |
| 389 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 390 | ok($doc->parse, 'Parse document'); |
| 391 | |
| 392 | is($doc->text_sigle, 'REDEW/DOC1/00558', 'Correct text sigle'); |
| 393 | is($doc->doc_sigle, 'REDEW/DOC1', 'Correct document sigle'); |
| 394 | is($doc->corpus_sigle, 'REDEW', 'Correct corpus sigle'); |
| 395 | |
| 396 | $meta = $doc->meta; |
| 397 | |
| 398 | # Tokenization |
| 399 | use_ok('KorAP::XML::Tokenizer'); |
| 400 | |
| 401 | ($token_base_foundry, $token_base_layer) = (qw/rwk Morpho/); |
| 402 | |
| 403 | # Get tokenization |
| 404 | $tokens = KorAP::XML::Tokenizer->new( |
| 405 | path => $doc->path, |
| 406 | doc => $doc, |
| 407 | foundry => $token_base_foundry, |
| 408 | layer => $token_base_layer, |
| 409 | name => 'tokens' |
| 410 | ); |
| 411 | |
| 412 | ok($tokens, 'Token Object is fine'); |
| 413 | ok($tokens->parse, 'Token parsing is fine'); |
| 414 | |
| 415 | $output = decode_json( $tokens->to_json ); |
| 416 | |
| 417 | 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'); |
| 418 | |
| 419 | # Add annotations |
| 420 | ok($tokens->add('RWK', 'Morpho')); |
| 421 | ok($tokens->add('RWK', 'Structure')); |
| 422 | |
| 423 | $output = decode_json( $tokens->to_json ); |
| 424 | |
| 425 | $first = $output->{data}->{stream}->[0]; |
| 426 | |
Akron | 56deacb | 2020-08-10 10:03:55 +0200 | [diff] [blame^] | 427 | is('-:base/paragraphs$<i>1',$first->[0]); |
Akron | e3e0536 | 2020-06-16 17:19:09 +0200 | [diff] [blame] | 428 | is('-:base/sentences$<i>68',$first->[1]); |
| 429 | |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 430 | done_testing; |