Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
| 4 | use Data::Dumper; |
| 5 | use JSON::XS; |
| 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 | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 11 | use Benchmark qw/:hireswallclock/; |
| 12 | |
| 13 | my $t = Benchmark->new; |
| 14 | |
| 15 | use utf8; |
| 16 | use lib 'lib', '../lib'; |
| 17 | |
| 18 | use File::Basename 'dirname'; |
| 19 | use File::Spec::Functions 'catdir'; |
| 20 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 21 | use_ok('KorAP::XML::Krill'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 22 | |
| 23 | # GOE/AGA/03828 |
Akron | 414ec95 | 2020-08-03 15:48:43 +0200 | [diff] [blame] | 24 | my $path = catdir(dirname(__FILE__), 'corpus','GOE','AGA','03828'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 25 | # my $path = '/home/ndiewald/Repositories/korap/KorAP-sandbox/KorAP-lucene-indexer/t/GOE/AGA/03828'; |
| 26 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 27 | ok(my $doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 28 | ok($doc->parse, 'Parse document'); |
| 29 | |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 30 | is($doc->text_sigle, 'GOE/AGA/03828', 'Correct text sigle'); |
| 31 | is($doc->doc_sigle, 'GOE/AGA', 'Correct document sigle'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 32 | is($doc->corpus_sigle, 'GOE', 'Correct corpus sigle'); |
| 33 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 34 | my $meta = $doc->meta; |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 35 | is($meta->{T_title}, 'Autobiographische Einzelheiten', 'Title'); |
| 36 | is($meta->{S_pub_place}, 'München', 'PubPlace'); |
| 37 | is($meta->{D_pub_date}, '19820000', 'Creation Date'); |
| 38 | ok(!$meta->{T_sub_title}, 'SubTitle'); |
| 39 | is($meta->{T_author}, 'Goethe, Johann Wolfgang von', 'Author'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 40 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 41 | is($meta->{A_publisher}, 'Verlag C. H. Beck', 'Publisher'); |
| 42 | ok(!$meta->{A_editor}, 'Publisher'); |
| 43 | is($meta->{S_text_type}, 'Autobiographie', 'Correct Text Type'); |
| 44 | ok(!$meta->{S_text_type_art}, 'Correct Text Type Art'); |
| 45 | ok(!$meta->{S_text_type_ref}, 'Correct Text Type Ref'); |
| 46 | ok(!$meta->{S_text_column}, 'Correct Text Column'); |
| 47 | ok(!$meta->{S_text_domain}, 'Correct Text Domain'); |
| 48 | is($meta->{D_creation_date}, '18200000', 'Creation Date'); |
| 49 | is($meta->{S_availability}, 'QAO-NC', 'License'); |
| 50 | is($meta->{A_src_pages}, '529-547', 'Pages'); |
| 51 | ok(!$meta->{A_file_edition_statement}, 'File Ed Statement'); |
| 52 | ok(!$meta->{A_bibl_edition_statement}, 'Bibl Ed Statement'); |
| 53 | is($meta->{A_reference} . "\n", <<'REF', 'Author'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 54 | Goethe, Johann Wolfgang von: Autobiographische Einzelheiten, (Geschrieben bis 1832), In: Goethe, Johann Wolfgang von: Goethes Werke, Bd. 10, Autobiographische Schriften II, Hrsg.: Trunz, Erich. München: Verlag C. H. Beck, 1982, S. 529-547 |
| 55 | REF |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 56 | is($meta->{S_language}, 'de', 'Language'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 57 | |
| 58 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 59 | is($meta->{T_corpus_title}, 'Goethes Werke', 'Correct Corpus title'); |
| 60 | ok(!$meta->{T_corpus_sub_title}, 'Correct Corpus Sub title'); |
| 61 | is($meta->{T_corpus_author}, 'Goethe, Johann Wolfgang von', 'Correct Corpus author'); |
| 62 | is($meta->{A_corpus_editor}, 'Trunz, Erich', 'Correct Corpus editor'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 63 | |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 64 | is($meta->{T_doc_title}, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)', |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 65 | 'Correct Doc title'); |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 66 | ok(!$meta->{T_doc_sub_title}, 'Correct Doc Sub title'); |
| 67 | ok(!$meta->{T_doc_author}, 'Correct Doc author'); |
| 68 | ok(!$meta->{A_doc_editor}, 'Correct Doc editor'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 69 | |
| 70 | # Tokenization |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 71 | use_ok('KorAP::XML::Tokenizer'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 72 | |
| 73 | my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/); |
| 74 | |
| 75 | # Get tokenization |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 76 | my $tokens = KorAP::XML::Tokenizer->new( |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 77 | path => $doc->path, |
| 78 | doc => $doc, |
| 79 | foundry => $token_base_foundry, |
| 80 | layer => $token_base_layer, |
| 81 | name => 'tokens' |
| 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), 'Autobiographische einzelheiten Selbstschilderung (1) immer tätiger, nach innen und außen fortwirkend', 'Primary Data'); |
| 89 | is($output->{data}->{name}, 'tokens', 'tokenName'); |
| 90 | is($output->{data}->{tokenSource}, 'opennlp#tokens', 'tokenSource'); |
| 91 | is($output->{version}, '0.03', 'version'); |
| 92 | is($output->{data}->{foundries}, '', 'Foundries'); |
| 93 | is($output->{data}->{layerInfos}, '', 'layerInfos'); |
Akron | 2d83a5a | 2016-02-26 00:21:16 +0100 | [diff] [blame] | 94 | is($output->{data}->{stream}->[0]->[4], 's:Autobiographische', 'data'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 95 | |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 96 | is($output->{textSigle}, 'GOE/AGA/03828', 'Correct text sigle'); |
| 97 | is($output->{docSigle}, 'GOE/AGA', 'Correct document sigle'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 98 | is($output->{corpusSigle}, 'GOE', 'Correct corpus sigle'); |
| 99 | |
| 100 | is($output->{author}, 'Goethe, Johann Wolfgang von', 'Author'); |
| 101 | is($output->{pubPlace}, 'München', 'PubPlace'); |
| 102 | is($output->{pubDate}, '19820000', 'Creation Date'); |
| 103 | is($output->{title}, 'Autobiographische Einzelheiten', 'Title'); |
| 104 | ok(!exists $output->{subTitle}, 'subTitle'); |
| 105 | |
| 106 | is($output->{publisher}, 'Verlag C. H. Beck', 'Publisher'); |
Akron | 5eb3aa0 | 2019-01-25 18:30:47 +0100 | [diff] [blame] | 107 | ok(!exists $output->{A_editor}, 'Editor'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 108 | is($output->{textType}, 'Autobiographie', 'Correct Text Type'); |
| 109 | ok(!exists $output->{textTypeArt}, 'Correct Text Type'); |
| 110 | ok(!exists $output->{textTypeRef}, 'Correct Text Type'); |
| 111 | ok(!exists $output->{textColumn}, 'Correct Text Type'); |
| 112 | ok(!exists $output->{textDomain}, 'Correct Text Type'); |
| 113 | is($output->{creationDate}, '18200000', 'Creation Date'); |
Akron | 6396c30 | 2016-03-18 16:05:39 +0100 | [diff] [blame] | 114 | is($output->{availability}, 'QAO-NC', 'License'); |
Akron | 08d5445 | 2017-02-16 23:19:49 +0100 | [diff] [blame] | 115 | is($output->{srcPages}, '529-547', 'Pages'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 116 | ok(!exists $output->{fileEditionStatement}, 'Correct Text Type'); |
| 117 | ok(!exists $output->{biblEditionStatement}, 'Correct Text Type'); |
| 118 | is($output->{reference} . "\n", <<'REF', 'Author'); |
| 119 | Goethe, Johann Wolfgang von: Autobiographische Einzelheiten, (Geschrieben bis 1832), In: Goethe, Johann Wolfgang von: Goethes Werke, Bd. 10, Autobiographische Schriften II, Hrsg.: Trunz, Erich. München: Verlag C. H. Beck, 1982, S. 529-547 |
| 120 | REF |
| 121 | is($output->{language}, 'de', 'Language'); |
| 122 | |
| 123 | is($output->{corpusTitle}, 'Goethes Werke', 'Correct Corpus title'); |
| 124 | ok(!exists $output->{corpusSubTitle}, 'Correct Text Type'); |
| 125 | is($output->{corpusAuthor}, 'Goethe, Johann Wolfgang von', 'Correct Corpus title'); |
| 126 | is($output->{corpusEditor}, 'Trunz, Erich', 'Editor'); |
| 127 | |
| 128 | is($output->{docTitle}, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)', 'Correct Corpus title'); |
| 129 | ok(!exists $output->{docSubTitle}, 'Correct Text Type'); |
| 130 | ok(!exists $output->{docAuthor}, 'Correct Text Type'); |
| 131 | ok(!exists $output->{docEditor}, 'Correct Text Type'); |
| 132 | |
| 133 | ## Base |
| 134 | $tokens->add('Base', 'Sentences'); |
| 135 | $tokens->add('Base', 'Paragraphs'); |
| 136 | |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 137 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 138 | |
| 139 | is($output->{data}->{foundries}, 'base base/paragraphs base/sentences', 'Foundries'); |
| 140 | is($output->{data}->{layerInfos}, 'base/s=spans', 'layerInfos'); |
| 141 | my $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 142 | like($first_token, qr/s:Autobiographische/, 'data'); |
| 143 | like($first_token, qr/_0\$<i>0<i>17/, 'data'); |
| 144 | like($first_token, qr!<>:base/s:s\$<b>64<i>0<i>30<i>2<b>2!, 'data'); |
Akron | dec4312 | 2020-03-03 11:22:25 +0100 | [diff] [blame] | 145 | like($first_token, qr!<>:base\/s:t\$<b>64<i>0<i>35199<i>5227<b>0!, 'data'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 146 | |
| 147 | ## OpenNLP |
| 148 | $tokens->add('OpenNLP', 'Sentences'); |
| 149 | |
| 150 | $output = decode_json( $tokens->to_json ); |
| 151 | is($output->{data}->{foundries}, |
| 152 | 'base base/paragraphs base/sentences opennlp opennlp/sentences', |
| 153 | 'Foundries'); |
| 154 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/s=spans', 'layerInfos'); |
| 155 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 156 | like($first_token, qr!<>:opennlp/s:s\$<b>64<i>0<i>254<i>32!, 'data'); |
| 157 | |
| 158 | $tokens->add('OpenNLP', 'Morpho'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 159 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 160 | is($output->{data}->{foundries}, |
| 161 | 'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences', |
| 162 | 'Foundries'); |
| 163 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans', 'layerInfos'); |
| 164 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 165 | like($first_token, qr!opennlp/p:ADJA!, 'data'); |
| 166 | |
| 167 | ## Treetagger |
| 168 | $tokens->add('TreeTagger', 'Sentences'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 169 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 170 | is($output->{data}->{foundries}, |
| 171 | 'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/sentences', |
| 172 | 'Foundries'); |
| 173 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/s=spans', 'layerInfos'); |
| 174 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 175 | like($first_token, qr!<>:tt/s:s\$<b>64<i>0<i>179<i>21<b>0!, 'data'); |
| 176 | |
| 177 | $tokens->add('TreeTagger', 'Morpho'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 178 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 179 | is($output->{data}->{foundries}, |
| 180 | 'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences', |
| 181 | 'Foundries'); |
| 182 | |
| 183 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos'); |
| 184 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Akron | 0426176 | 2018-01-29 20:16:39 +0100 | [diff] [blame] | 185 | like($first_token, qr!tt/l:autobiographisch!, 'data'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 186 | like($first_token, qr!tt/p:ADJA\$<b>129<b>165!, 'data'); |
Akron | 0426176 | 2018-01-29 20:16:39 +0100 | [diff] [blame] | 187 | like($first_token, qr!tt/l:Autobiographische!, 'data'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 188 | like($first_token, qr!tt/p:NN\$<b>129<b>89!, 'data'); |
| 189 | |
| 190 | ## CoreNLP |
| 191 | $tokens->add('CoreNLP', 'NamedEntities'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 192 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 193 | is($output->{data}->{foundries}, |
| 194 | 'base base/paragraphs base/sentences corenlp corenlp/namedentities opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences', |
| 195 | 'Foundries'); |
| 196 | is($output->{data}->{layerInfos}, 'base/s=spans corenlp/ne=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos'); |
| 197 | |
| 198 | # diag "Missing test for NamedEntities"; |
| 199 | |
| 200 | # Problematic: |
| 201 | # diag Dumper $output->{data}->{stream}->[180]; |
| 202 | # diag Dumper $output->{data}->{stream}->[341]; |
| 203 | |
| 204 | $tokens->add('CoreNLP', 'Sentences'); |
| 205 | $output = decode_json( $tokens->to_json ); |
| 206 | is($output->{data}->{foundries}, |
| 207 | 'base base/paragraphs base/sentences corenlp corenlp/namedentities corenlp/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences', |
| 208 | 'Foundries'); |
| 209 | is($output->{data}->{layerInfos}, 'base/s=spans corenlp/ne=tokens corenlp/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos'); |
| 210 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 211 | like($first_token, qr!<>:corenlp/s:s\$<b>64<i>0<i>254<i>32<b>0!, 'data'); |
| 212 | |
| 213 | $tokens->add('CoreNLP', 'Morpho'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 214 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 215 | like($output->{data}->{foundries}, qr!corenlp/morpho!, 'Foundries'); |
| 216 | like($output->{data}->{layerInfos}, qr!corenlp/p=tokens!, 'layerInfos'); |
| 217 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 218 | like($first_token, qr!corenlp/p:ADJA!, 'data'); |
| 219 | |
| 220 | $tokens->add('CoreNLP', 'Constituency'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 221 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 222 | like($output->{data}->{foundries}, qr!corenlp/constituency!, 'Foundries'); |
| 223 | like($output->{data}->{layerInfos}, qr!corenlp/c=spans!, 'layerInfos'); |
| 224 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 225 | like($first_token, qr!<>:corenlp/c:NP\$<b>64<i>0<i>17<i>1<b>6!, 'data'); |
| 226 | like($first_token, qr!<>:corenlp/c:CNP\$<b>64<i>0<i>17<i>1<b>7!, 'data'); |
| 227 | like($first_token, qr!<>:corenlp/c:NP\$<b>64<i>0<i>17<i>1<b>8!, 'data'); |
| 228 | like($first_token, qr!<>:corenlp/c:AP\$<b>64<i>0<i>17<i>1<b>9!, 'data'); |
| 229 | like($first_token, qr!<>:corenlp/c:PP\$<b>64<i>0<i>50<i>3<b>4!, 'data'); |
| 230 | like($first_token, qr!<>:corenlp/c:S\$<b>64<i>0<i>50<i>3<b>5!, 'data'); |
| 231 | like($first_token, qr!<>:corenlp/c:PP\$<b>64<i>0<i>58<i>5<b>2!, 'data'); |
| 232 | like($first_token, qr!<>:corenlp/c:S\$<b>64<i>0<i>58<i>5<b>3!, 'data'); |
| 233 | like($first_token, qr!<>:corenlp/c:ROOT\$<b>64<i>0<i>254<i>32<b>0!, 'data'); |
| 234 | like($first_token, qr!<>:corenlp/c:S\$<b>64<i>0<i>254<i>32<b>1!, 'data'); |
| 235 | |
| 236 | ## Glemm |
| 237 | $tokens->add('Glemm', 'Morpho'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 238 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 239 | like($output->{data}->{foundries}, qr!glemm/morpho!, 'Foundries'); |
| 240 | like($output->{data}->{layerInfos}, qr!glemm/l=tokens!, 'layerInfos'); |
| 241 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 242 | like($first_token, qr!glemm/l:__autobiographisch!, 'data'); |
| 243 | like($first_token, qr!glemm/l:\+_Auto!, 'data'); |
| 244 | like($first_token, qr!glemm/l:\+_biographisch!, 'data'); |
| 245 | like($first_token, qr!glemm/l:\+\+Biograph!, 'data'); |
| 246 | like($first_token, qr!glemm/l:\+\+-isch!, 'data'); |
| 247 | |
| 248 | ## Connexor |
| 249 | $tokens->add('Connexor', 'Sentences'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 250 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 251 | like($output->{data}->{foundries}, qr!connexor/sentences!, 'Foundries'); |
| 252 | like($output->{data}->{layerInfos}, qr!cnx/s=spans!, 'layerInfos'); |
| 253 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 254 | like($first_token, qr!<>:cnx/s:s\$<b>64<i>0<i>179<i>21<b>0!, 'data'); |
| 255 | |
| 256 | $tokens->add('Connexor', 'Morpho'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 257 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 258 | like($output->{data}->{foundries}, qr!connexor/morpho!, 'Foundries'); |
| 259 | like($output->{data}->{layerInfos}, qr!cnx/p=tokens!, 'layerInfos'); |
| 260 | like($output->{data}->{layerInfos}, qr!cnx/l=tokens!, 'layerInfos'); |
| 261 | like($output->{data}->{layerInfos}, qr!cnx/m=tokens!, 'layerInfos'); |
| 262 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 263 | like($first_token, qr!cnx/l:autobiografisch!, 'data'); |
| 264 | like($first_token, qr!cnx/p:A!, 'data'); |
| 265 | |
| 266 | $tokens->add('Connexor', 'Phrase'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 267 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 268 | like($output->{data}->{foundries}, qr!connexor/phrase!, 'Foundries'); |
| 269 | like($output->{data}->{layerInfos}, qr!cnx/c=spans!, 'layerInfos'); |
| 270 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 271 | like($first_token, qr!<>:cnx/c:np\$<b>64<i>0<i>30<i>2!, 'data'); |
| 272 | |
| 273 | $tokens->add('Connexor', 'Syntax'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 274 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 275 | like($output->{data}->{foundries}, qr!connexor/syntax!, 'Foundries'); |
| 276 | like($output->{data}->{layerInfos}, qr!cnx/syn=tokens!, 'layerInfos'); |
| 277 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 278 | like($first_token, qr!cnx/syn:\@PREMOD!, 'data'); |
| 279 | |
| 280 | ## Mate |
| 281 | $tokens->add('Mate', 'Morpho'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 282 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 283 | like($output->{data}->{foundries}, qr!mate/morpho!, 'Foundries'); |
| 284 | like($output->{data}->{layerInfos}, qr!mate/p=tokens!, 'layerInfos'); |
| 285 | like($output->{data}->{layerInfos}, qr!mate/l=tokens!, 'layerInfos'); |
| 286 | like($output->{data}->{layerInfos}, qr!mate/m=tokens!, 'layerInfos'); |
| 287 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 288 | like($first_token, qr!mate/l:autobiographisch!, 'data'); |
| 289 | like($first_token, qr!mate/p:NN!, 'data'); |
| 290 | like($first_token, qr!mate/m:case:nom!, 'data'); |
| 291 | like($first_token, qr!mate/m:number:pl!, 'data'); |
| 292 | like($first_token, qr!mate/m:gender:\*!, 'data'); |
| 293 | |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 294 | ## XIP |
| 295 | $tokens->add('XIP', 'Sentences'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 296 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 297 | like($output->{data}->{foundries}, qr!xip/sentences!, 'Foundries'); |
| 298 | like($output->{data}->{layerInfos}, qr!xip/s=spans!, 'layerInfos'); |
| 299 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 300 | like($first_token, qr!<>:xip/s:s\$<b>64<i>0<i>179<i>21!, 'data'); |
| 301 | |
| 302 | $tokens->add('XIP', 'Morpho'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 303 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 304 | like($output->{data}->{foundries}, qr!xip/morpho!, 'Foundries'); |
| 305 | like($output->{data}->{layerInfos}, qr!xip/l=tokens!, 'layerInfos'); |
| 306 | like($output->{data}->{layerInfos}, qr!xip/p=tokens!, 'layerInfos'); |
| 307 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 308 | like($first_token, qr!<>:xip/s:s\$<b>64<i>0<i>179<i>21!, 'data'); |
| 309 | |
| 310 | $tokens->add('XIP', 'Constituency'); |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 311 | $output = $tokens->to_data; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 312 | like($output->{data}->{foundries}, qr!xip/constituency!, 'Foundries'); |
| 313 | like($output->{data}->{layerInfos}, qr!xip/c=spans!, 'layerInfos'); |
| 314 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
| 315 | like($first_token, qr!<>:xip/c:NP\$<b>64<i>0<i>17<i>1<b>1!, 'data'); |
| 316 | like($first_token, qr!<>:xip/c:AP\$<b>64<i>0<i>17<i>1<b>2!, 'data'); |
| 317 | like($first_token, qr!<>:xip/c:ADJ\$<b>64<i>0<i>17<i>1<b>3!, 'data'); |
| 318 | like($first_token, qr!<>:xip/c:TOP\$<b>64<i>0<i>179<i>21<b>0!, 'data'); |
| 319 | |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 320 | # diag "No test for mate dependency"; |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 321 | # diag "No test for xip dependency"; |
| 322 | |
Akron | d3a0bad | 2016-02-26 14:07:58 +0100 | [diff] [blame] | 323 | # diag timestr(timediff(Benchmark->new, $t)); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 324 | |
| 325 | done_testing; |
| 326 | __END__ |