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