Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
| 4 | use Data::Dumper; |
| 5 | use JSON::XS; |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [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 | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 11 | use utf8; |
| 12 | use lib 'lib', '../lib'; |
| 13 | |
| 14 | use File::Basename 'dirname'; |
| 15 | use File::Spec::Functions 'catdir'; |
| 16 | |
| 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','REI','BNG','00128'); |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [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, 'REI/BNG/00128', 'Correct text sigle'); |
| 25 | is($doc->doc_sigle, 'REI/BNG', 'Correct document sigle'); |
| 26 | is($doc->corpus_sigle, 'REI', 'Correct corpus sigle'); |
| 27 | |
| 28 | my $meta = $doc->meta; |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 29 | is($meta->{T_title}, 'Friedensgutachten der führenden Friedensforschungsinstitute', 'Title'); |
| 30 | is($meta->{T_sub_title}, 'Rede im Deutschen Bundestag am 14.06.2002', 'SubTitle'); |
| 31 | is($meta->{T_author}, 'Nachtwei, Winfried', 'Author'); |
| 32 | ok(!$meta->{A_editor}, 'Editor'); |
| 33 | is($meta->{S_pub_place}, 'Berlin', 'PubPlace'); |
| 34 | ok(!$meta->{A_publisher}, 'Publisher'); |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 35 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 36 | ok(!$meta->{S_text_type}, 'No 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'); |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 41 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 42 | is($meta->{K_text_class}->[0], 'politik', 'Correct Text Class'); |
| 43 | is($meta->{K_text_class}->[1], 'inland', 'Correct Text Class'); |
| 44 | ok(!$meta->{K_text_class}->[2], 'Correct Text Class'); |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 45 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 46 | is($meta->{D_pub_date}, '20020614', 'Creation date'); |
| 47 | is($meta->{D_creation_date}, '20020614', 'Creation date'); |
| 48 | is($meta->{S_availability}, 'CC-BY-SA', 'License'); |
| 49 | ok(!$meta->{A_pages}, 'Pages'); |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 50 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 51 | ok(!$meta->{A_file_edition_statement}, 'File Statement'); |
| 52 | ok(!$meta->{A_bibl_edition_statement}, 'Bibl Statement'); |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 53 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 54 | is($meta->{A_reference} . "\n", <<'REF', 'Reference'); |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 55 | Nachtwei, Winfried: Friedensgutachten der führenden Friedensforschungsinstitute. Rede im Deutschen Bundestag am 14.06.2002, Hrsg: Bundestagsfraktion Bündnis 90/DIE GRÜNEN [Ausführliche Zitierung nicht verfügbar] |
| 56 | REF |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 57 | is($meta->{S_language}, 'de', 'Language'); |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 58 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 59 | is($meta->{T_corpus_title}, 'Reden und Interviews', 'Correct Corpus title'); |
| 60 | ok(!$meta->{T_corpus_sub_title}, 'Correct Corpus sub title'); |
| 61 | ok(!$meta->{T_corpus_author}, 'Correct Corpus author'); |
| 62 | ok(!$meta->{A_corpus_editor}, 'Correct Corpus editor'); |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 63 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 64 | is($meta->{T_doc_title}, 'Reden der Bundestagsfraktion Bündnis 90/DIE GRÜNEN, (2002-2006)', 'Correct Doc title'); |
| 65 | ok(!$meta->{T_doc_sub_title}, 'Correct Doc sub title'); |
| 66 | ok(!$meta->{T_doc_author}, 'Correct Doc author'); |
| 67 | ok(!$meta->{A_doc_editor}, 'Correct doc editor'); |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 68 | |
| 69 | # Tokenization |
| 70 | use_ok('KorAP::XML::Tokenizer'); |
| 71 | |
| 72 | my ($token_base_foundry, $token_base_layer) = (qw/Base tokens_conservative/); |
| 73 | |
| 74 | # Get tokenization |
| 75 | my $tokens = KorAP::XML::Tokenizer->new( |
| 76 | path => $doc->path, |
| 77 | doc => $doc, |
| 78 | foundry => $token_base_foundry, |
| 79 | layer => $token_base_layer, |
| 80 | name => 'tokens' |
| 81 | ); |
| 82 | |
| 83 | ok($tokens, 'Token Object is fine'); |
| 84 | ok($tokens->parse, 'Token parsing is fine'); |
| 85 | |
| 86 | my $output = decode_json( $tokens->to_json ); |
| 87 | |
| 88 | is(substr($output->{data}->{text}, 0, 100), 'Winfried Nachtwei, Friedensgutachten der führenden Friedensforschungsinstitute 14. Juni 2002 Vizeprä', 'Primary Data'); |
| 89 | |
| 90 | is($output->{data}->{name}, 'tokens', 'tokenName'); |
| 91 | is($output->{data}->{tokenSource}, 'base#tokens_conservative', 'tokenSource'); |
| 92 | is($output->{version}, '0.03', 'version'); |
| 93 | |
| 94 | is($output->{data}->{foundries}, '', 'Foundries'); |
| 95 | is($output->{data}->{layerInfos}, '', 'layerInfos'); |
| 96 | is($output->{data}->{stream}->[0]->[4], 's:Winfried', 'data'); |
| 97 | |
| 98 | is($output->{textSigle}, 'REI/BNG/00128', 'Correct text sigle'); |
| 99 | is($output->{docSigle}, 'REI/BNG', 'Correct document sigle'); |
| 100 | is($output->{corpusSigle}, 'REI', 'Correct corpus sigle'); |
| 101 | |
| 102 | is($output->{title}, 'Friedensgutachten der führenden Friedensforschungsinstitute', 'Title'); |
| 103 | is($output->{subTitle}, 'Rede im Deutschen Bundestag am 14.06.2002', 'Correct SubTitle'); |
| 104 | is($output->{author}, 'Nachtwei, Winfried', 'Author'); |
| 105 | ok(!exists $output->{editor}, 'Publisher'); |
| 106 | |
| 107 | is($output->{pubPlace}, 'Berlin', 'PubPlace'); |
| 108 | ok(!exists $output->{publisher}, 'Publisher'); |
| 109 | |
| 110 | ok(!exists $output->{textType}, 'Correct Text Type'); |
| 111 | ok(!exists $output->{textTypeArt}, 'Correct Text Type Art'); |
| 112 | ok(!exists $output->{textTypeRef}, 'Correct Text Type Ref'); |
| 113 | ok(!exists $output->{textDomain}, 'Correct Text Domain'); |
| 114 | |
| 115 | is($output->{creationDate}, '20020614', 'Creation date'); |
| 116 | is($output->{availability}, 'CC-BY-SA', 'License'); |
| 117 | |
| 118 | ok(!exists $output->{pages}, 'Pages'); |
| 119 | ok(!exists $output->{fileEditionStatement}, 'File Statement'); |
| 120 | ok(!exists $output->{biblEditionStatement}, 'Bibl Statement'); |
| 121 | |
| 122 | is($output->{reference} . "\n", <<'REF', 'Reference'); |
| 123 | Nachtwei, Winfried: Friedensgutachten der führenden Friedensforschungsinstitute. Rede im Deutschen Bundestag am 14.06.2002, Hrsg: Bundestagsfraktion Bündnis 90/DIE GRÜNEN [Ausführliche Zitierung nicht verfügbar] |
| 124 | REF |
| 125 | is($output->{language}, 'de', 'Language'); |
| 126 | |
| 127 | is($output->{corpusTitle}, 'Reden und Interviews', 'Correct Corpus title'); |
| 128 | ok(!exists $output->{corpusSubTitle}, 'Correct Corpus sub title'); |
| 129 | ok(!exists $output->{corpusAuthor}, 'Correct Corpus author'); |
| 130 | ok(!exists $output->{corpusEditor}, 'Correct Corpus editor'); |
| 131 | |
| 132 | is($output->{docTitle}, 'Reden der Bundestagsfraktion Bündnis 90/DIE GRÜNEN, (2002-2006)', 'Correct Doc title'); |
| 133 | ok(!exists $output->{docSubTitle}, 'Correct Doc sub title'); |
| 134 | ok(!exists $output->{docAuthor}, 'Correct Doc author'); |
| 135 | ok(!exists $output->{docEditor}, 'Correct doc editor'); |
| 136 | |
| 137 | ## Base |
| 138 | $tokens->add('Base', 'Sentences'); |
| 139 | $tokens->add('Base', 'Paragraphs'); |
| 140 | |
| 141 | $output = decode_json( $tokens->to_json ); |
| 142 | |
| 143 | is($output->{data}->{foundries}, 'base base/paragraphs base/sentences', 'Foundries'); |
| 144 | is($output->{data}->{layerInfos}, 'base/s=spans', 'layerInfos'); |
| 145 | my $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 146 | like($first_token, qr/s:Winfried/, 'data'); |
| 147 | like($first_token, qr/_0\$<i>0<i>8/, 'data'); |
| 148 | |
| 149 | |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 150 | # REI/RBR/00610 |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 151 | $path = catdir(dirname(__FILE__), 'corpus','REI','RBR','00610'); |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 152 | |
| 153 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 154 | ok($doc->parse, 'Parse document'); |
| 155 | |
| 156 | # Get tokenization |
| 157 | $tokens = KorAP::XML::Tokenizer->new( |
| 158 | path => $doc->path, |
| 159 | doc => $doc, |
| 160 | foundry => $token_base_foundry, |
| 161 | layer => $token_base_layer, |
| 162 | name => 'tokens' |
| 163 | ); |
| 164 | |
| 165 | ok($tokens, 'Token Object is fine'); |
| 166 | ok($tokens->parse, 'Token parsing is fine'); |
| 167 | |
| 168 | # Add annotations |
| 169 | $tokens->add('Base', 'Sentences'); |
| 170 | $tokens->add('Base', 'Paragraphs'); |
| 171 | |
| 172 | $tokens->add('CoreNLP', 'Constituency'); |
| 173 | $tokens->add('CoreNLP', 'Morpho'); |
| 174 | $tokens->add('CoreNLP', 'Sentences'); |
| 175 | |
| 176 | $tokens->add('Malt', 'Dependency'); |
| 177 | |
| 178 | $tokens->add('OpenNLP', 'Morpho'); |
| 179 | $tokens->add('OpenNLP', 'Sentences'); |
| 180 | |
| 181 | $tokens->add('DeReKo', 'Structure'); |
| 182 | |
| 183 | $tokens->add('TreeTagger', 'Morpho'); |
| 184 | $tokens->add('TreeTagger', 'Sentences'); |
| 185 | |
| 186 | $output = decode_json( $tokens->to_json ); |
| 187 | |
| 188 | my $first = $output->{data}->{stream}->[0]; |
| 189 | is('-:base/paragraphs$<i>31', $first->[0]); |
| 190 | is('-:base/sentences$<i>168', $first->[1]); |
| 191 | is('-:corenlp/sentences$<i>175', $first->[2]); |
| 192 | is('-:opennlp/sentences$<i>169', $first->[3]); |
| 193 | is('-:tokens$<i>2641', $first->[4]); |
| 194 | is('-:tt/sentences$<i>196', $first->[5]); |
| 195 | is('<:malt/d:PP$<b>32<i>4', $first->[6]); |
| 196 | is('<>:corenlp/c:ROOT$<b>64<i>0<i>48<i>7<b>0', $first->[7]); |
| 197 | is('<>:corenlp/s:s$<b>64<i>0<i>48<i>7<b>0', $first->[8]); |
| 198 | is('<>:opennlp/s:s$<b>64<i>0<i>48<i>7<b>0', $first->[9]); |
| 199 | is('<>:tt/s:s$<b>64<i>0<i>48<i>7<b>0', $first->[10]); |
| 200 | is('<>:corenlp/c:S$<b>64<i>0<i>48<i>7<b>1', $first->[11]); |
| 201 | is('<>:dereko/s:front$<b>64<i>0<i>91<i>11<b>1', $first->[12]); |
| 202 | is('<>:base/s:s$<b>64<i>0<i>91<i>11<b>2', $first->[13]); |
| 203 | is('<>:dereko/s:titlePage$<b>64<i>0<i>91<i>11<b>2<s>1', $first->[14]); |
| 204 | is('<>:dereko/s:docTitle$<b>64<i>0<i>91<i>11<b>3', $first->[15]); |
| 205 | is('<>:dereko/s:titlePart$<b>64<i>0<i>91<i>11<b>4<s>2', $first->[16]); |
| 206 | is('<>:dereko/s:s$<b>64<i>0<i>91<i>11<b>5', $first->[17]); |
Akron | dec4312 | 2020-03-03 11:22:25 +0100 | [diff] [blame] | 207 | is('<>:base/s:t$<b>64<i>0<i>17859<i>2641<b>0', $first->[18]); |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 208 | is('>:malt/d:ROOT$<b>33<i>0<i>48<i>0<i>7', $first->[19]); |
| 209 | is('<:malt/d:PP$<b>32<i>1', $first->[20]); |
| 210 | is('<:malt/d:ROOT$<b>34<i>0<i>48<i>7<i>0', $first->[21]); |
| 211 | is('@:dereko/s:id:rbr.00610-0-titlepage$<b>17<s>1<i>11', $first->[22]); |
| 212 | is('@:dereko/s:type:unspecified$<b>17<s>2<i>11', $first->[23]); |
| 213 | is('_0$<i>0<i>4', $first->[24]); |
| 214 | is('corenlp/p:NN', $first->[25]); |
| 215 | is('i:rede', $first->[26]); |
| 216 | is('opennlp/p:NN', $first->[27]); |
| 217 | is('s:Rede', $first->[28]); |
Akron | 28dc17f | 2018-02-01 15:31:41 +0100 | [diff] [blame] | 218 | is('tt/l:Rede$<b>129<b>253', $first->[29]); |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 219 | is('tt/p:NN$<b>129<b>253', $first->[30]); |
| 220 | |
| 221 | my $last = $output->{data}->{stream}->[-1]; |
| 222 | |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 223 | # Milestones behind the final token are no longer indexed |
| 224 | # is('<>:dereko/s:text$<b>65<i>17859<i>17859<i>2640<b>0', $last->[0]); |
| 225 | # is('<>:dereko/s:back$<b>65<i>17859<i>17859<i>2640<b>1', $last->[1]); |
| 226 | is('>:malt/d:APP$<b>32<i>2639', $last->[0]); |
| 227 | is('_2640$<i>17851<i>17859', $last->[1]); |
| 228 | is('corenlp/p:NE', $last->[2]); |
| 229 | is("i:schr\x{f6}der", $last->[3]); |
| 230 | is('opennlp/p:NE', $last->[4]); |
| 231 | is("s:Schr\x{f6}der", $last->[5]); |
| 232 | is("tt/l:Schr\x{f6}der", $last->[6]); |
| 233 | is('tt/p:NE', $last->[7]); |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 234 | |
| 235 | |
| 236 | # REI/BNG/00071 |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 237 | $path = catdir(dirname(__FILE__), 'corpus','REI','BNG','00071'); |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 238 | |
| 239 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 240 | ok($doc->parse, 'Parse document'); |
| 241 | |
| 242 | # Get tokenization |
| 243 | $tokens = KorAP::XML::Tokenizer->new( |
| 244 | path => $doc->path, |
| 245 | doc => $doc, |
| 246 | foundry => $token_base_foundry, |
| 247 | layer => $token_base_layer, |
| 248 | name => 'tokens' |
| 249 | ); |
| 250 | |
| 251 | ok($tokens, 'Token Object is fine'); |
| 252 | ok($tokens->parse, 'Token parsing is fine'); |
| 253 | |
| 254 | # Add annotations |
| 255 | $tokens->add('Base', 'Sentences'); |
| 256 | $tokens->add('Base', 'Paragraphs'); |
| 257 | |
| 258 | $tokens->add('CoreNLP', 'Constituency'); |
| 259 | $tokens->add('CoreNLP', 'Morpho'); |
| 260 | $tokens->add('CoreNLP', 'Sentences'); |
| 261 | |
| 262 | $tokens->add('Malt', 'Dependency'); |
| 263 | |
| 264 | $tokens->add('OpenNLP', 'Morpho'); |
| 265 | $tokens->add('OpenNLP', 'Sentences'); |
| 266 | |
| 267 | $tokens->add('DeReKo', 'Structure'); |
| 268 | |
| 269 | $tokens->add('TreeTagger', 'Morpho'); |
| 270 | $tokens->add('TreeTagger', 'Sentences'); |
| 271 | |
| 272 | $output = decode_json( $tokens->to_json ); |
| 273 | |
| 274 | $first = $output->{data}->{stream}->[0]; |
| 275 | |
| 276 | is('-:base/paragraphs$<i>41', $first->[0]); |
| 277 | is('-:base/sentences$<i>73', $first->[1]); |
| 278 | is('-:corenlp/sentences$<i>69', $first->[2]); |
| 279 | is('-:opennlp/sentences$<i>65', $first->[3]); |
| 280 | is('-:tokens$<i>1009', $first->[4]); |
Akron | b62d92a | 2020-03-01 16:32:00 +0100 | [diff] [blame] | 281 | is('-:tt/sentences$<i>94', $first->[5]); |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 282 | is('<:malt/d:APP$<b>32<i>1', $first->[6]); |
| 283 | is('<>:corenlp/c:MPN$<b>64<i>0<i>16<i>2<b>3', $first->[7]); |
| 284 | is('<>:base/s:s$<b>64<i>0<i>48<i>5<b>2', $first->[8]); |
| 285 | is('<>:dereko/s:titlePart$<b>64<i>0<i>48<i>5<b>4<s>2', $first->[9]); |
| 286 | is('<>:dereko/s:s$<b>64<i>0<i>48<i>5<b>5', $first->[10]); |
| 287 | is('<>:corenlp/c:ROOT$<b>64<i>0<i>51<i>6<b>0', $first->[11]); |
| 288 | is('<>:corenlp/s:s$<b>64<i>0<i>51<i>6<b>0', $first->[12]); |
| 289 | is('<>:tt/s:s$<b>64<i>0<i>51<i>6<b>0', $first->[13]); |
| 290 | is('<>:corenlp/c:NUR$<b>64<i>0<i>51<i>6<b>1', $first->[14]); |
| 291 | is('<>:corenlp/c:NP$<b>64<i>0<i>50<i>6<b>2', $first->[15]); |
| 292 | is('<>:dereko/s:front$<b>64<i>0<i>61<i>8<b>1', $first->[16]); |
| 293 | is('<>:dereko/s:titlePage$<b>64<i>0<i>61<i>8<b>2<s>1', $first->[17]); |
| 294 | is('<>:dereko/s:docTitle$<b>64<i>0<i>61<i>8<b>3', $first->[18]); |
| 295 | is('<>:opennlp/s:s$<b>64<i>0<i>173<i>24<b>0', $first->[19]); |
Akron | dec4312 | 2020-03-03 11:22:25 +0100 | [diff] [blame] | 296 | is('<>:base/s:t$<b>64<i>0<i>7008<i>1009<b>0', $first->[20]); |
| 297 | is('<>:dereko/s:text$<b>64<i>0<i>7008<i>1009<b>0', $first->[21]); |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 298 | is('>:malt/d:GMOD$<b>32<i>3', $first->[22]); |
| 299 | is('<:malt/d:ROOT$<b>34<i>0<i>51<i>6<i>3', $first->[23]); |
| 300 | is('@:dereko/s:id:bng.00071-0-titlepage$<b>17<s>1<i>8', $first->[24]); |
| 301 | is('@:dereko/s:type:unspecified$<b>17<s>2<i>5', $first->[25]); |
| 302 | is('_0$<i>0<i>9', $first->[26]); |
| 303 | is('corenlp/p:NE', $first->[27]); |
| 304 | is('i:christine', $first->[28]); |
| 305 | is('opennlp/p:NE', $first->[29]); |
| 306 | is('s:Christine', $first->[30]); |
Akron | 0426176 | 2018-01-29 20:16:39 +0100 | [diff] [blame] | 307 | is('tt/l:Christine', $first->[31]); |
Akron | 28dc17f | 2018-02-01 15:31:41 +0100 | [diff] [blame] | 308 | is('tt/p:NE', $first->[32]); |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 309 | |
| 310 | $last = $output->{data}->{stream}->[-1]; |
Akron | dec4312 | 2020-03-03 11:22:25 +0100 | [diff] [blame] | 311 | # No longer indexed: |
| 312 | #is('<>:dereko/s:back$<b>65<i>7008<i>7008<i>1009<b>1', $last->[0]); |
| 313 | #is('<>:dereko/s:div$<b>65<i>7008<i>7008<i>1009<b>2<s>1', $last->[1]); |
| 314 | #is('@:dereko/s:n:1$<b>17<s>1', $last->[2]); |
| 315 | #is('@:dereko/s:type:footnotes$<b>17<s>1', $last->[3]); |
| 316 | #is('@:dereko/s:complete:y$<b>17<s>1', $last->[4]); |
| 317 | is('_1008$<i>6990<i>7006', $last->[0]); |
| 318 | is('corenlp/p:NN', $last->[1]); |
| 319 | is('i:befreiungsschlag', $last->[2]); |
| 320 | is('opennlp/p:NN', $last->[3]); |
| 321 | is('s:Befreiungsschlag', $last->[4]); |
Akron | a5920b1 | 2016-06-29 18:51:21 +0200 | [diff] [blame] | 322 | |
Akron | 0ffbd52 | 2021-02-16 12:01:19 +0100 | [diff] [blame] | 323 | |
| 324 | # Check with negative level (required for wikidemo conversion) |
| 325 | $path = catdir(dirname(__FILE__), 'corpus','REI','RBP','00007'); |
| 326 | |
| 327 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 328 | ok($doc->parse, 'Parse document'); |
| 329 | |
| 330 | is($doc->text_sigle, 'REI/RBP/00007', 'Correct text sigle'); |
| 331 | is($doc->doc_sigle, 'REI/RBP', 'Correct document sigle'); |
| 332 | is($doc->corpus_sigle, 'REI', 'Correct corpus sigle'); |
| 333 | |
| 334 | $meta = $doc->meta; |
| 335 | is($meta->{T_title}, 'Ansprache von Bundespräsident Richard von Weizsäcker bei einem Abendessen, gegeben von Königin Beatrix und Prinz Claus im Königlichen Palais Op de Dam', 'Title'); |
| 336 | ok(!$meta->{T_sub_title}, 'SubTitle'); |
| 337 | is($meta->{T_author}, 'Richard von Weizsäcker', 'Author'); |
| 338 | ok(!$meta->{A_editor}, 'Editor'); |
| 339 | is($meta->{S_pub_place}, 'Bonnn', 'PubPlace'); # sic! |
| 340 | ok(!$meta->{A_publisher}, 'Publisher'); |
| 341 | |
| 342 | ok(!$meta->{S_text_type}, 'No Text Type'); |
| 343 | ok(!$meta->{S_text_type_art}, 'No Text Type Art'); |
| 344 | ok(!$meta->{S_text_type_ref}, 'No Text Type Ref'); |
| 345 | ok(!$meta->{S_text_domain}, 'No Text Domain'); |
| 346 | ok(!$meta->{S_text_column}, 'No Text Column'); |
| 347 | |
| 348 | is($meta->{K_text_class}->[0], 'politik', 'Correct Text Class'); |
| 349 | is($meta->{K_text_class}->[1], 'ausland', 'Correct Text Class'); |
| 350 | ok(!$meta->{K_text_class}->[2], 'Correct Text Class'); |
| 351 | |
| 352 | is($meta->{D_pub_date}, '19850530', 'Creation date'); |
| 353 | is($meta->{D_creation_date}, '19850530', 'Creation date'); |
| 354 | is($meta->{S_availability}, 'CC-BY-SA', 'License'); |
| 355 | ok(!$meta->{A_pages}, 'Pages'); |
| 356 | |
| 357 | ok(!$meta->{A_file_edition_statement}, 'File Statement'); |
| 358 | ok(!$meta->{A_bibl_edition_statement}, 'Bibl Statement'); |
| 359 | |
| 360 | # Get tokenization |
| 361 | $tokens = KorAP::XML::Tokenizer->new( |
| 362 | path => $doc->path, |
| 363 | doc => $doc, |
| 364 | foundry => $token_base_foundry, |
| 365 | layer => 'tokens', |
| 366 | name => 'tokens' |
| 367 | ); |
| 368 | |
| 369 | ok($tokens, 'Token Object is fine'); |
| 370 | ok($tokens->parse, 'Token parsing is fine'); |
| 371 | ok(!$tokens->error); |
| 372 | |
| 373 | $tokens->add('DeReKo', 'Structure', 'base-sentences-paragraphs-pagebreaks'); |
| 374 | ok(!$tokens->error); |
| 375 | |
| 376 | $output = decode_json( $tokens->to_json ); |
| 377 | |
| 378 | is(substr($output->{data}->{text}, 0, 100), 'Ansprache von Bundespräsident Richard von Weizsäcker bei einem Abendessen, gegeben von Königin Beatr', 'Primary Data'); |
| 379 | |
| 380 | is($output->{data}->{foundries}, 'dereko dereko/structure dereko/structure/base-sentences-paragraphs-pagebreaks', 'Foundries'); |
| 381 | is($output->{data}->{layerInfos}, 'dereko/s=spans', 'layerInfos'); |
| 382 | |
| 383 | my $stream = $output->{data}->{stream}; |
| 384 | |
| 385 | is($stream->[0]->[0], '-:base/paragraphs$<i>3'); |
| 386 | is($stream->[0]->[1], '-:base/sentences$<i>16'); |
| 387 | is($stream->[0]->[2], '-:tokens$<i>418'); |
| 388 | is($stream->[0]->[7], '<>:base/s:s$<b>64<i>0<i>353<i>53<b>2'); |
| 389 | is($stream->[0]->[8], '<>:base/s:t$<b>64<i>0<i>2664<i>418<b>0'); |
| 390 | |
| 391 | is(index(join('',@{$stream->[0]}), '<>:dereko/s:s$'), -1); |
| 392 | |
Akron | 1924bbe | 2016-06-22 16:05:41 +0200 | [diff] [blame] | 393 | done_testing; |
| 394 | __END__ |