Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | # source ~/perl5/perlbrew/etc/bashrc |
| 3 | # perlbrew switch perl-blead@korap |
| 4 | use strict; |
| 5 | use warnings; |
| 6 | use utf8; |
| 7 | use Test::More; |
| 8 | use Benchmark ':hireswallclock'; |
| 9 | use lib 'lib', '../lib'; |
| 10 | use Scalar::Util qw/weaken/; |
| 11 | |
| 12 | use File::Basename 'dirname'; |
| 13 | use File::Spec::Functions 'catdir'; |
| 14 | |
| 15 | use_ok('KorAP::Document'); |
| 16 | |
| 17 | my $path = catdir(dirname(__FILE__), 'artificial'); |
| 18 | ok(my $doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 19 | like($doc->path, qr!$path/$!, 'Path'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 20 | ok($doc->parse, 'Parse document'); |
| 21 | |
| 22 | sub new_tokenizer { |
| 23 | my $x = $doc; |
| 24 | weaken $x; |
| 25 | return KorAP::Tokenizer->new( |
| 26 | path => $x->path, |
| 27 | doc => $x, |
| 28 | foundry => 'OpenNLP', |
| 29 | layer => 'Tokens', |
| 30 | name => 'tokens' |
| 31 | ) |
| 32 | }; |
| 33 | |
| 34 | is($doc->primary->data, |
| 35 | 'Zum letzten kulturellen Anlass lädt die Leitung des Schulheimes Hofbergli ein, '. |
| 36 | 'bevor der Betrieb Ende Schuljahr eingestellt wird.', 'Primary data'); |
| 37 | |
| 38 | is($doc->primary->data_length, 129, 'Primary data length'); |
| 39 | |
| 40 | is($doc->primary->data(0,3), 'Zum', 'Get primary data'); |
| 41 | |
| 42 | # Get tokens |
| 43 | use_ok('KorAP::Tokenizer'); |
| 44 | # Get tokenization |
| 45 | ok(my $tokens = KorAP::Tokenizer->new( |
| 46 | path => $doc->path, |
| 47 | doc => $doc, |
| 48 | foundry => 'OpenNLP', |
| 49 | layer => 'Tokens', |
| 50 | name => 'tokens' |
| 51 | ), 'New Tokenizer'); |
| 52 | ok($tokens->parse, 'Parse'); |
| 53 | |
| 54 | is($tokens->foundry, 'OpenNLP', 'Foundry'); |
| 55 | |
Nils Diewald | 7ec5153 | 2014-10-28 19:51:26 +0000 | [diff] [blame] | 56 | is($tokens->doc->text_sigle, 'ART_ABC.00001', 'Doc id'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 57 | is($tokens->should, 20, 'Should'); |
| 58 | is($tokens->have, 18, 'Have'); |
| 59 | is($tokens->name, 'tokens', 'Name'); |
| 60 | is($tokens->layer, 'Tokens', 'Layer'); |
| 61 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 62 | is($tokens->stream->pos(0)->to_string, '[(0-3)-:tokens$<i>18|_0#0-3|i:zum|s:Zum]', 'Token is correct'); |
| 63 | |
| 64 | is($tokens->stream->pos(1)->to_string, '[(4-11)_1#4-11|i:letzten|s:letzten]', 'Token is correct'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 65 | |
| 66 | my $i = 2; |
| 67 | foreach ([12,23, 'kulturellen'], |
| 68 | [24,30, 'Anlass'], |
| 69 | [31,35, 'lädt'], |
| 70 | [36,39, 'die'], |
| 71 | [40,47, 'Leitung'], |
| 72 | [48,51, 'des'], |
| 73 | [52,63, 'Schulheimes'], |
| 74 | [64,73, 'Hofbergli'], |
| 75 | [74,77, 'ein'], |
| 76 | [79,84, 'bevor'], |
| 77 | [85,88, 'der'], |
| 78 | [89,96, 'Betrieb'], |
| 79 | [97,101, 'Ende'], |
| 80 | [102,111, 'Schuljahr'], |
| 81 | [112,123, 'eingestellt'], |
| 82 | [124,128, 'wird'] |
| 83 | ) { |
| 84 | is($tokens->stream->pos($i++)->to_string, |
| 85 | '[('.$_->[0].'-'.$_->[1].')'. |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 86 | '_'.($i-1).'#'.$_->[0].'-'.$_->[1] . '|' . |
| 87 | 'i:'.lc($_->[2]).'|s:'.$_->[2].']', |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 88 | 'Token is correct'); |
| 89 | }; |
| 90 | |
| 91 | ok(!$tokens->stream->pos($i++), 'No more tokens'); |
| 92 | |
| 93 | # Add OpenNLP/morpho |
| 94 | ok($tokens->add('OpenNLP', 'Morpho'), 'Add OpenNLP/Morpho'); |
| 95 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 96 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 97 | $i = 0; |
| 98 | foreach (qw/APPRART ADJA ADJA NN VVFIN ART NN ART NN NE PTKVZ KOUS ART NN NN NN VVPP VAFIN/) { |
| 99 | like($tokens->stream->pos($i++)->to_string, |
| 100 | qr!\|opennlp/p:$_!, |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 101 | 'Annotation (OpenNLP/p) is correct: ' . $_ |
| 102 | ); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | # Add OpenNLP/sentences |
| 106 | ok($tokens->add('OpenNLP', 'Sentences'), 'Add OpenNLP/Sentences'); |
| 107 | |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 108 | is($tokens->stream->pos(0)->to_string, |
| 109 | '[(0-3)-:opennlp/sentences$<i>1|-:tokens$<i>18|<>:opennlp/s:s#0-129$<i>17<b>0|_0#0-3|i:zum|opennlp/p:APPRART|s:Zum]', |
| 110 | # '[(0-3)-:opennlp/sentences$<i>1|-:tokens$<i>18|_0#0-3|i:zum|s:Zum|opennlp/p:APPRART|<>:opennlp/s:s#0-129$<i>17]', |
| 111 | 'Correct sentence' |
| 112 | ); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 113 | |
| 114 | # New instantiation |
| 115 | ok($tokens = KorAP::Tokenizer->new( |
| 116 | path => $doc->path, |
| 117 | doc => $doc, |
| 118 | foundry => 'OpenNLP', |
| 119 | layer => 'Tokens', |
| 120 | name => 'tokens' |
| 121 | ), 'New Tokenizer'); |
| 122 | |
| 123 | ok($tokens->parse, 'Parse'); |
| 124 | |
| 125 | # Add OpenNLP/sentences |
| 126 | ok($tokens->add('Base', 'Sentences'), 'Add Base/Sentences'); |
| 127 | |
| 128 | # Add OpenNLP/sentences |
| 129 | ok($tokens->add('Base', 'Paragraphs'), 'Add Base/Paragraphs'); |
| 130 | |
| 131 | is($tokens->stream->pos(0)->to_string, |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 132 | '[(0-3)-:base/paragraphs$<i>0|-:base/sentences$<i>1|-:tokens$<i>18|<>:base/s:t#0-129$<i>17<b>0|<>:base/s:s#0-129$<i>17<b>2|_0#0-3|i:zum|s:Zum]', |
| 133 | # '[(0-3)-:base/paragraphs$<i>0|-:base/sentences$<i>1|-:tokens$<i>18|_0#0-3|i:zum|s:Zum|<>:base/s:t#0-129$<i>17<b>0|<>:base/s:s#0-129$<i>17<b>0]', |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 134 | 'Correct base annotation'); |
| 135 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 136 | # New instantiation |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 137 | ok($tokens = new_tokenizer->parse, 'Parse'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 138 | |
| 139 | # Add CoreNLP/NamedEntities |
| 140 | ok($tokens->add('CoreNLP', 'NamedEntities', 'ne_dewac_175m_600'), 'Add CoreNLP/NamedEntities'); |
| 141 | ok($tokens->add('CoreNLP', 'NamedEntities', 'ne_hgc_175m_600'), 'Add CoreNLP/NamedEntities'); |
| 142 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 143 | # [(64-73)s:Hofbergli|i:hofbergli|_9#64-73|corenlp/ne_dewac_175m_600:I-LOC|corenlp/ne_hgc_175m_600:I-LOC] |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 144 | is($tokens->stream->pos(9)->to_string, |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 145 | '[(64-73)_9#64-73|corenlp/ne:I-LOC|i:hofbergli|s:Hofbergli]', |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 146 | 'Correct NamedEntities annotation'); |
| 147 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 148 | # New instantiation |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 149 | ok($tokens = new_tokenizer->parse, 'Parse'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 150 | |
| 151 | # Add CoreNLP/Morpho |
| 152 | ok($tokens->add('CoreNLP', 'Morpho'), 'Add CoreNLP/Morpho'); |
| 153 | |
| 154 | is($tokens->stream->pos(0)->to_string, |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 155 | '[(0-3)-:tokens$<i>18|_0#0-3|corenlp/p:APPRART|i:zum|s:Zum]', |
| 156 | # '[(0-3)-:tokens$<i>18|_0#0-3|i:zum|s:Zum|corenlp/p:APPRART]', |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 157 | 'Correct corenlp annotation'); |
| 158 | |
| 159 | $i = 0; |
| 160 | foreach (qw/APPRART ADJ ADJA NN VVFIN ART NN ART NN NE PTKVZ KOUS ART NN NN NN VVPP VAFIN/) { |
| 161 | like($tokens->stream->pos($i++)->to_string, |
| 162 | qr!\|corenlp/p:$_!, |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 163 | 'Annotation (CoreNLP/p) is correct: '. $_); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 164 | }; |
| 165 | |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 166 | |
| 167 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 168 | # Add CoreNLP/Sentences |
| 169 | ok($tokens->add('CoreNLP', 'Sentences'), 'Add CoreNLP/Sentences'); |
| 170 | |
| 171 | is($tokens->stream->pos(0)->to_string, |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 172 | '[(0-3)-:corenlp/sentences$<i>1|-:tokens$<i>18|<>:corenlp/s:s#0-129$<i>17<b>0|_0#0-3|corenlp/p:APPRART|i:zum|s:Zum]', |
| 173 | # '[(0-3)-:corenlp/sentences$<i>1|-:tokens$<i>18|_0#0-3|i:zum|s:Zum|corenlp/p:APPRART|<>:corenlp/s:s#0-129$<i>17]', |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 174 | 'Correct corenlp annotation'); |
| 175 | |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 176 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 177 | # New instantiation |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 178 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 179 | |
| 180 | # Add CoreNLP/Sentences |
| 181 | ok($tokens->add('Connexor', 'Sentences'), 'Add Connexor/Sentences'); |
| 182 | |
| 183 | is($tokens->stream->pos(0)->to_string, |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 184 | '[(0-3)-:cnx/sentences$<i>1|-:tokens$<i>18|<>:cnx/s:s#0-129$<i>17<b>0|_0#0-3|i:zum|s:Zum]', |
| 185 | # '[(0-3)-:cnx/sentences$<i>1|-:tokens$<i>18|_0#0-3|i:zum|s:Zum|<>:cnx/s:s#0-129$<i>17<b>0]', |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 186 | 'Correct cnx annotation'); |
| 187 | |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 188 | # New instantiation |
| 189 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 190 | |
| 191 | # Add Connexor/Morpho |
| 192 | ok($tokens->add('Connexor', 'Morpho'), 'Add Connexor/Morpho'); |
| 193 | |
| 194 | $i = 0; |
| 195 | foreach (qw/! A A N V DET N DET N N NUM CS DET N N N V V/) { |
| 196 | if ($_ eq '!') { |
| 197 | $i++; |
| 198 | next; |
| 199 | }; |
| 200 | like($tokens->stream->pos($i++)->to_string, |
| 201 | qr!\|cnx/p:$_!, |
| 202 | 'Annotation (Connexor/p) is correct: ' . $_); |
| 203 | }; |
| 204 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 205 | |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 206 | $i = 0; |
| 207 | foreach (qw/! ! ! ! IND:PRES ! ! ! ! Prop ! ! ! ! ! ! PCP:PERF IND:PRES/) { |
| 208 | if ($_ eq '!') { |
| 209 | $i++; |
| 210 | next; |
| 211 | }; |
| 212 | foreach my $f (split(':', $_)) { |
| 213 | like($tokens->stream->pos($i)->to_string, |
| 214 | qr!\|cnx/m:$f!, |
| 215 | 'Annotation (Connexor/m) is correct: '. $f); |
| 216 | }; |
| 217 | $i++; |
| 218 | }; |
| 219 | |
| 220 | # New instantiation |
| 221 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 222 | |
| 223 | # Add Connexor/Phrase |
| 224 | ok($tokens->add('Connexor', 'Phrase'), 'Add Connexor/Phrase'); |
| 225 | my $stream = $tokens->stream; |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 226 | like($stream->pos(1)->to_string, qr!<>:cnx/c:np#4-30\$<i>4<b>0!, 'Annotation (Connexor/c) is correct'); |
| 227 | like($stream->pos(6)->to_string, qr!<>:cnx/c:np#40-47\$<i>7<b>0!, 'Annotation (Connexor/c) is correct'); |
| 228 | like($stream->pos(8)->to_string, qr!<>:cnx/c:np#52-73\$<i>10<b>0!, 'Annotation (Connexor/c) is correct'); |
| 229 | like($stream->pos(13)->to_string, qr!<>:cnx/c:np#89-111\$<i>16<b>0!, 'Annotation (Connexor/c) is correct'); |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 230 | |
| 231 | # New instantiation |
| 232 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 233 | |
| 234 | # Add Connexor/Syntax |
| 235 | ok($tokens->add('Connexor', 'Syntax'), 'Add Connexor/Syntax'); |
| 236 | $stream = $tokens->stream; |
| 237 | |
| 238 | $i = 0; |
| 239 | foreach (qw/! @PREMOD @PREMOD @NH @MAIN @PREMOD @NH @PREMOD |
| 240 | @PREMOD @NH @NH @PREMARK @PREMOD @PREMOD @NH @NH @MAIN @AUX/) { |
| 241 | if ($_ eq '!') { |
| 242 | $i++; |
| 243 | next; |
| 244 | }; |
| 245 | like($tokens->stream->pos($i++)->to_string, |
| 246 | qr!\|cnx/syn:$_!, |
| 247 | 'Annotation (Connexor/syn) is correct: ' . $_); |
| 248 | }; |
| 249 | |
| 250 | # New instantiation |
| 251 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 252 | |
| 253 | # Add XIP/Sentences |
| 254 | ok($tokens->add('XIP', 'Sentences'), 'Add XIP/Sentences'); |
| 255 | |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 256 | is($tokens->stream->pos(0)->to_string, |
| 257 | '[(0-3)-:tokens$<i>18|-:xip/sentences$<i>1|<>:xip/s:s#0-129$<i>17<b>0|_0#0-3|i:zum|s:Zum]', |
| 258 | # '[(0-3)-:tokens$<i>18|_0#0-3|i:zum|s:Zum|-:xip/sentences$<i>1|<>:xip/s:s#0-129$<i>17<b>0]', |
| 259 | 'First sentence' |
| 260 | ); |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 261 | |
| 262 | # Add XIP/Morpho |
| 263 | ok($tokens->add('XIP', 'Morpho'), 'Add XIP/Morpho'); |
| 264 | $stream = $tokens->stream; |
| 265 | |
| 266 | $i = 0; |
| 267 | foreach (qw/PREP ADJ ADJ NOUN VERB DET NOUN DET NOUN NOUN PTCL CONJ DET NOUN NOUN NOUN VERB VERB/) { |
| 268 | if ($_ eq '!') { |
| 269 | $i++; |
| 270 | next; |
| 271 | }; |
| 272 | like($tokens->stream->pos($i++)->to_string, |
| 273 | qr!\|xip/p:$_!, |
| 274 | 'Annotation (xip/p) is correct: ' . $_); |
| 275 | }; |
| 276 | |
| 277 | $i = 0; |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 278 | foreach ('zu', 'letzt', 'kulturell', 'Anlass', '=laden:laden', 'die', 'Leitung', 'der', '\#schulen:\#Heim:schulen\#Heim', 'Hofbergli', 'ein', 'bevor', 'der', 'Betrieb', 'Ende', '\#schulen:\#Jahr:schulen\#Jahr') { |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 279 | if ($_ eq '!') { |
| 280 | $i++; |
| 281 | next; |
| 282 | }; |
| 283 | foreach my $f (split(':', $_)) { |
| 284 | like($tokens->stream->pos($i)->to_string, |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 285 | qr!\|xip\/l:\Q$f\E!, |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 286 | 'Annotation (xip/l) is correct: ' . $f); |
| 287 | }; |
| 288 | $i++; |
| 289 | }; |
| 290 | |
| 291 | # New instantiation |
| 292 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 293 | |
| 294 | # Add XIP/Sentences |
Nils Diewald | 47c3ef3 | 2014-04-30 19:13:17 +0000 | [diff] [blame] | 295 | ok($tokens->add('XIP', 'Dependency'), 'Add XIP/Dependency'); |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 296 | |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 297 | |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 298 | $stream = $tokens->stream; |
| 299 | like($stream->pos(1)->to_string, qr!\|>:xip/d:NMOD\$<i>3!, 'Dependency fine'); |
| 300 | like($stream->pos(3)->to_string, qr!\|<:xip/d:NMOD\$<i>1!, 'Dependency fine'); |
| 301 | like($stream->pos(3)->to_string, qr!\|<:xip/d:NMOD\$<i>2!, 'Dependency fine'); |
| 302 | like($stream->pos(4)->to_string, qr!\|>xip/d:VMAIN\$<i>4!, 'Dependency fine'); |
| 303 | like($stream->pos(4)->to_string, qr!\|<:xip/d:SUBJ\$<i>6!, 'Dependency fine'); |
| 304 | like($stream->pos(4)->to_string, qr!\|<:xip/d:VPREF\$<i>10!, 'Dependency fine'); |
| 305 | like($stream->pos(5)->to_string, qr!\|>:xip/d:DETERM\$<i>6!, 'Dependency fine'); |
| 306 | like($stream->pos(6)->to_string, qr!\|<:xip/d:DETERM\$<i>5!, 'Dependency fine'); |
| 307 | like($stream->pos(6)->to_string, qr!\|>:xip/d:SUBJ\$<i>4!, 'Dependency fine'); |
| 308 | like($stream->pos(6)->to_string, qr!\|<:xip/d:NMOD\$<i>8!, 'Dependency fine'); |
| 309 | like($stream->pos(7)->to_string, qr!\|>:xip/d:DETERM\$<i>8!, 'Dependency fine'); |
| 310 | like($stream->pos(8)->to_string, qr!\|<:xip/d:DETERM\$<i>7!, 'Dependency fine'); |
| 311 | like($stream->pos(8)->to_string, qr!\|>:xip/d:NMOD\$<i>6!, 'Dependency fine'); |
| 312 | like($stream->pos(8)->to_string, qr!\|<:xip/d:NMOD\$<i>9!, 'Dependency fine'); |
| 313 | like($stream->pos(9)->to_string, qr!\|>:xip/d:NMOD\$<i>8!, 'Dependency fine'); |
| 314 | like($stream->pos(10)->to_string, qr!\|>:xip/d:VPREF\$<i>4!, 'Dependency fine'); |
| 315 | like($stream->pos(11)->to_string, qr!\|>:xip/d:CONNECT\$<i>16!, 'Dependency fine'); |
| 316 | like($stream->pos(12)->to_string, qr!\|>:xip/d:DETERM\$<i>13!, 'Dependency fine'); |
| 317 | like($stream->pos(13)->to_string, qr!\|<:xip/d:DETERM\$<i>12!, 'Dependency fine'); |
| 318 | like($stream->pos(13)->to_string, qr!\|>:xip/d:SUBJ\$<i>16!, 'Dependency fine'); |
| 319 | like($stream->pos(14)->to_string, qr!\|>:xip/d:OBJ\$<i>16!, 'Dependency fine'); |
| 320 | like($stream->pos(15)->to_string, qr!\|>:xip/d:OBJ\$<i>16!, 'Dependency fine'); |
| 321 | like($stream->pos(16)->to_string, qr!\|<:xip/d:CONNECT\$<i>11!, 'Dependency fine'); |
| 322 | like($stream->pos(16)->to_string, qr!\|<:xip/d:SUBJ\$<i>13!, 'Dependency fine'); |
| 323 | like($stream->pos(16)->to_string, qr!\|<:xip/d:OBJ\$<i>14!, 'Dependency fine'); |
| 324 | like($stream->pos(16)->to_string, qr!\|<:xip/d:OBJ\$<i>15!, 'Dependency fine'); |
| 325 | like($stream->pos(16)->to_string, qr!\|>:xip/d:AUXIL\$<i>17!, 'Dependency fine'); |
| 326 | like($stream->pos(16)->to_string, qr!\|>xip/d:VMAIN\$<i>16!, 'Dependency fine'); |
| 327 | like($stream->pos(16)->to_string, qr!\|<xip/d:VMAIN\$<i>16!, 'Dependency fine'); |
| 328 | like($stream->pos(17)->to_string, qr!\|<:xip/d:AUXIL\$<i>16!, 'Dependency fine'); |
| 329 | |
Nils Diewald | 47c3ef3 | 2014-04-30 19:13:17 +0000 | [diff] [blame] | 330 | # New instantiation |
| 331 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 332 | |
| 333 | # Add XIP/Sentences |
| 334 | ok($tokens->add('XIP', 'Constituency'), 'Add XIP/Constituency'); |
| 335 | |
| 336 | $stream = $tokens->stream; |
| 337 | like($stream->pos(0)->to_string, qr!\|<>:xip/c:TOP#0-129\$<i>17!, 'Constituency fine'); |
| 338 | like($stream->pos(0)->to_string, qr!\|<>:xip/c:MC#0-129\$<i>17<b>1!, 'Constituency fine'); |
| 339 | like($stream->pos(0)->to_string, qr!\|<>:xip/c:PP#0-30\$<i>4<b>2!, 'Constituency fine'); |
| 340 | like($stream->pos(0)->to_string, qr!\|<>:xip/c:PREP#0-3\$<i>1!, 'Constituency fine'); |
| 341 | |
| 342 | like($stream->pos(1)->to_string, qr!\|<>:xip/c:NP#4-30\$<i>4<b>3!, 'Constituency fine'); |
| 343 | like($stream->pos(1)->to_string, qr!\|<>:xip/c:NPA#4-30\$<i>4<b>4!, 'Constituency fine'); |
| 344 | like($stream->pos(1)->to_string, qr!\|<>:xip/c:AP#4-11\$<i>2<b>5!, 'Constituency fine'); |
| 345 | like($stream->pos(1)->to_string, qr!\|<>:xip/c:ADJ#4-11\$<i>2<b>6!, 'Constituency fine'); |
| 346 | |
| 347 | like($stream->pos(2)->to_string, qr!\|<>:xip/c:AP#12-23\$<i>3<b>5!, 'Constituency fine'); |
| 348 | like($stream->pos(2)->to_string, qr!\|<>:xip/c:ADJ#12-23\$<i>3<b>6!, 'Constituency fine'); |
| 349 | |
| 350 | like($stream->pos(3)->to_string, qr!\|<>:xip/c:NOUN#24-30\$<i>4<b>5!, 'Constituency fine'); |
| 351 | |
| 352 | like($stream->pos(4)->to_string, qr!\|<>:xip/c:VERB#31-35\$<i>5<b>2!, 'Constituency fine'); |
| 353 | |
| 354 | like($stream->pos(5)->to_string, qr!\|<>:xip/c:NP#36-47\$<i>7<b>2!, 'Constituency fine'); |
| 355 | like($stream->pos(5)->to_string, qr!\|<>:xip/c:DET#36-39\$<i>6<b>3!, 'Constituency fine'); |
| 356 | |
| 357 | like($stream->pos(6)->to_string, qr!\|<>:xip/c:NPA#40-47\$<i>7<b>3!, 'Constituency fine'); |
| 358 | like($stream->pos(6)->to_string, qr!\|<>:xip/c:NOUN#40-47\$<i>7<b>4!, 'Constituency fine'); |
| 359 | |
| 360 | like($stream->pos(7)->to_string, qr!\|<>:xip/c:NP#48-63\$<i>9<b>2!, 'Constituency fine'); |
| 361 | like($stream->pos(7)->to_string, qr!\|<>:xip/c:DET#48-51\$<i>8<b>3!, 'Constituency fine'); |
| 362 | |
| 363 | like($stream->pos(8)->to_string, qr!\|<>:xip/c:NPA#52-63\$<i>9<b>3!, 'Constituency fine'); |
| 364 | like($stream->pos(8)->to_string, qr!\|<>:xip/c:NOUN#52-63\$<i>9<b>4!, 'Constituency fine'); |
| 365 | |
| 366 | like($stream->pos(9)->to_string, qr!\|<>:xip/c:NP#64-73\$<i>10<b>2!, 'Constituency fine'); |
| 367 | like($stream->pos(9)->to_string, qr!\|<>:xip/c:NPA#64-73\$<i>10<b>3!, 'Constituency fine'); |
| 368 | like($stream->pos(9)->to_string, qr!\|<>:xip/c:NOUN#64-73\$<i>10<b>4!, 'Constituency fine'); |
| 369 | |
| 370 | like($stream->pos(10)->to_string, qr!\|<>:xip/c:PTCL#74-77\$<i>11<b>2!, 'Constituency fine'); |
| 371 | |
| 372 | like($stream->pos(11)->to_string, qr!\|<>:xip/c:SC#79-128\$<i>18!, 'Constituency fine'); |
| 373 | like($stream->pos(11)->to_string, qr!\|<>:xip/c:CONJ#79-84\$<i>12<b>1!, 'Constituency fine'); |
| 374 | |
| 375 | like($stream->pos(12)->to_string, qr!\|<>:xip/c:NP#85-96\$<i>14<b>1!, 'Constituency fine'); |
| 376 | like($stream->pos(12)->to_string, qr!\|<>:xip/c:DET#85-88\$<i>13<b>2!, 'Constituency fine'); |
| 377 | |
| 378 | |
| 379 | like($stream->pos(13)->to_string, qr!\|<>:xip/c:NPA#89-96\$<i>14<b>2!, 'Constituency fine'); |
| 380 | like($stream->pos(13)->to_string, qr!\|<>:xip/c:NOUN#89-96\$<i>14<b>3!, 'Constituency fine'); |
| 381 | |
| 382 | like($stream->pos(14)->to_string, qr!\|<>:xip/c:NP#97-101\$<i>15<b>1!, 'Constituency fine'); |
| 383 | like($stream->pos(14)->to_string, qr!\|<>:xip/c:NPA#97-101\$<i>15<b>2!, 'Constituency fine'); |
| 384 | like($stream->pos(14)->to_string, qr!\|<>:xip/c:NOUN#97-101\$<i>15<b>3!, 'Constituency fine'); |
| 385 | |
| 386 | like($stream->pos(15)->to_string, qr!\|<>:xip/c:NP#102-111\$<i>16<b>1!, 'Constituency fine'); |
| 387 | like($stream->pos(15)->to_string, qr!\|<>:xip/c:NPA#102-111\$<i>16<b>2!, 'Constituency fine'); |
| 388 | like($stream->pos(15)->to_string, qr!\|<>:xip/c:NOUN#102-111\$<i>16<b>3!, 'Constituency fine'); |
| 389 | |
| 390 | like($stream->pos(16)->to_string, qr!\|<>:xip/c:VERB#112-123\$<i>17<b>1!, 'Constituency fine'); |
| 391 | |
| 392 | like($stream->pos(17)->to_string, qr!\|<>:xip/c:VERB#124-128\$<i>18<b>1!, 'Constituency fine'); |
| 393 | |
| 394 | # diag $stream->to_string; |
| 395 | |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 396 | |
| 397 | # ADJA ADJA NN VVFIN ART NN ART NN NE PTKVZ KOUS ART NN NN NN VVPP VAFIN |
| 398 | done_testing; |
| 399 | __END__ |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 400 | |
| 401 | |
| 402 | # Todo: CoreNLP/Constituency! |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 403 | |
| 404 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 405 | |
| 406 | |
| 407 | |
| 408 | # Connexor |
| 409 | push(@layers, ['Connexor', 'Morpho']); |
| 410 | push(@layers, ['Connexor', 'Syntax']); |
| 411 | push(@layers, ['Connexor', 'Phrase']); |
| 412 | push(@layers, ['Connexor', 'Sentences']); |
| 413 | |
| 414 | # TreeTagger |
| 415 | push(@layers, ['TreeTagger', 'Morpho']); |
| 416 | push(@layers, ['TreeTagger', 'Sentences']); |
| 417 | |
| 418 | # Mate |
| 419 | # push(@layers, ['Mate', 'Morpho']); |
| 420 | push(@layers, ['Mate', 'Dependency']); |
| 421 | |
| 422 | # XIP |
| 423 | push(@layers, ['XIP', 'Morpho']); |
| 424 | push(@layers, ['XIP', 'Constituency']); |
| 425 | push(@layers, ['XIP', 'Dependency']); |
| 426 | push(@layers, ['XIP', 'Sentences']); |
| 427 | |
| 428 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 429 | __END__ |