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'); |
| 19 | is($doc->path, $path . '/', 'Path'); |
| 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 | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 108 | is($tokens->stream->pos(0)->to_string, '[(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]', 'Correct sentence'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 109 | |
| 110 | # New instantiation |
| 111 | ok($tokens = KorAP::Tokenizer->new( |
| 112 | path => $doc->path, |
| 113 | doc => $doc, |
| 114 | foundry => 'OpenNLP', |
| 115 | layer => 'Tokens', |
| 116 | name => 'tokens' |
| 117 | ), 'New Tokenizer'); |
| 118 | |
| 119 | ok($tokens->parse, 'Parse'); |
| 120 | |
| 121 | # Add OpenNLP/sentences |
| 122 | ok($tokens->add('Base', 'Sentences'), 'Add Base/Sentences'); |
| 123 | |
| 124 | # Add OpenNLP/sentences |
| 125 | ok($tokens->add('Base', 'Paragraphs'), 'Add Base/Paragraphs'); |
| 126 | |
| 127 | is($tokens->stream->pos(0)->to_string, |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 128 | '[(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] | 129 | 'Correct base annotation'); |
| 130 | |
| 131 | |
| 132 | # New instantiation |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 133 | ok($tokens = new_tokenizer->parse, 'Parse'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 134 | |
| 135 | # Add CoreNLP/NamedEntities |
| 136 | ok($tokens->add('CoreNLP', 'NamedEntities', 'ne_dewac_175m_600'), 'Add CoreNLP/NamedEntities'); |
| 137 | ok($tokens->add('CoreNLP', 'NamedEntities', 'ne_hgc_175m_600'), 'Add CoreNLP/NamedEntities'); |
| 138 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 139 | # [(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] | 140 | is($tokens->stream->pos(9)->to_string, |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 141 | '[(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] | 142 | 'Correct NamedEntities annotation'); |
| 143 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 144 | # New instantiation |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 145 | ok($tokens = new_tokenizer->parse, 'Parse'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 146 | |
| 147 | # Add CoreNLP/Morpho |
| 148 | ok($tokens->add('CoreNLP', 'Morpho'), 'Add CoreNLP/Morpho'); |
| 149 | |
| 150 | is($tokens->stream->pos(0)->to_string, |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 151 | '[(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] | 152 | 'Correct corenlp annotation'); |
| 153 | |
| 154 | $i = 0; |
| 155 | foreach (qw/APPRART ADJ ADJA NN VVFIN ART NN ART NN NE PTKVZ KOUS ART NN NN NN VVPP VAFIN/) { |
| 156 | like($tokens->stream->pos($i++)->to_string, |
| 157 | qr!\|corenlp/p:$_!, |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 158 | 'Annotation (CoreNLP/p) is correct: '. $_); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 159 | }; |
| 160 | |
| 161 | # Add CoreNLP/Sentences |
| 162 | ok($tokens->add('CoreNLP', 'Sentences'), 'Add CoreNLP/Sentences'); |
| 163 | |
| 164 | is($tokens->stream->pos(0)->to_string, |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 165 | '[(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] | 166 | 'Correct corenlp annotation'); |
| 167 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 168 | # New instantiation |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 169 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 170 | |
| 171 | # Add CoreNLP/Sentences |
| 172 | ok($tokens->add('Connexor', 'Sentences'), 'Add Connexor/Sentences'); |
| 173 | |
| 174 | is($tokens->stream->pos(0)->to_string, |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 175 | '[(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] | 176 | 'Correct cnx annotation'); |
| 177 | |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 178 | # New instantiation |
| 179 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 180 | |
| 181 | # Add Connexor/Morpho |
| 182 | ok($tokens->add('Connexor', 'Morpho'), 'Add Connexor/Morpho'); |
| 183 | |
| 184 | $i = 0; |
| 185 | foreach (qw/! A A N V DET N DET N N NUM CS DET N N N V V/) { |
| 186 | if ($_ eq '!') { |
| 187 | $i++; |
| 188 | next; |
| 189 | }; |
| 190 | like($tokens->stream->pos($i++)->to_string, |
| 191 | qr!\|cnx/p:$_!, |
| 192 | 'Annotation (Connexor/p) is correct: ' . $_); |
| 193 | }; |
| 194 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 195 | |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 196 | $i = 0; |
| 197 | foreach (qw/! ! ! ! IND:PRES ! ! ! ! Prop ! ! ! ! ! ! PCP:PERF IND:PRES/) { |
| 198 | if ($_ eq '!') { |
| 199 | $i++; |
| 200 | next; |
| 201 | }; |
| 202 | foreach my $f (split(':', $_)) { |
| 203 | like($tokens->stream->pos($i)->to_string, |
| 204 | qr!\|cnx/m:$f!, |
| 205 | 'Annotation (Connexor/m) is correct: '. $f); |
| 206 | }; |
| 207 | $i++; |
| 208 | }; |
| 209 | |
| 210 | # New instantiation |
| 211 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 212 | |
| 213 | # Add Connexor/Phrase |
| 214 | ok($tokens->add('Connexor', 'Phrase'), 'Add Connexor/Phrase'); |
| 215 | my $stream = $tokens->stream; |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 216 | like($stream->pos(1)->to_string, qr!\|<>:cnx/c:np#4-30\$<i>4<b>0!, 'Annotation (Connexor/c) is correct'); |
| 217 | like($stream->pos(6)->to_string, qr!\|<>:cnx/c:np#40-47\$<i>7<b>0!, 'Annotation (Connexor/c) is correct'); |
| 218 | like($stream->pos(8)->to_string, qr!\|<>:cnx/c:np#52-73\$<i>10<b>0!, 'Annotation (Connexor/c) is correct'); |
| 219 | 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] | 220 | |
| 221 | # New instantiation |
| 222 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 223 | |
| 224 | # Add Connexor/Syntax |
| 225 | ok($tokens->add('Connexor', 'Syntax'), 'Add Connexor/Syntax'); |
| 226 | $stream = $tokens->stream; |
| 227 | |
| 228 | $i = 0; |
| 229 | foreach (qw/! @PREMOD @PREMOD @NH @MAIN @PREMOD @NH @PREMOD |
| 230 | @PREMOD @NH @NH @PREMARK @PREMOD @PREMOD @NH @NH @MAIN @AUX/) { |
| 231 | if ($_ eq '!') { |
| 232 | $i++; |
| 233 | next; |
| 234 | }; |
| 235 | like($tokens->stream->pos($i++)->to_string, |
| 236 | qr!\|cnx/syn:$_!, |
| 237 | 'Annotation (Connexor/syn) is correct: ' . $_); |
| 238 | }; |
| 239 | |
| 240 | # New instantiation |
| 241 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 242 | |
| 243 | # Add XIP/Sentences |
| 244 | ok($tokens->add('XIP', 'Sentences'), 'Add XIP/Sentences'); |
| 245 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 246 | is($tokens->stream->pos(0)->to_string, '[(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]', 'First sentence'); |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 247 | |
| 248 | # Add XIP/Morpho |
| 249 | ok($tokens->add('XIP', 'Morpho'), 'Add XIP/Morpho'); |
| 250 | $stream = $tokens->stream; |
| 251 | |
| 252 | $i = 0; |
| 253 | foreach (qw/PREP ADJ ADJ NOUN VERB DET NOUN DET NOUN NOUN PTCL CONJ DET NOUN NOUN NOUN VERB VERB/) { |
| 254 | if ($_ eq '!') { |
| 255 | $i++; |
| 256 | next; |
| 257 | }; |
| 258 | like($tokens->stream->pos($i++)->to_string, |
| 259 | qr!\|xip/p:$_!, |
| 260 | 'Annotation (xip/p) is correct: ' . $_); |
| 261 | }; |
| 262 | |
| 263 | $i = 0; |
| 264 | foreach ('zu', 'letzt', 'kulturell', 'Anlass', '=laden:laden', 'die', 'Leitung', 'der', '#schulen:#Heim:schulen#Heim', 'Hofbergli', 'ein', 'bevor', 'der', 'Betrieb', 'Ende', '#schulen:#Jahr:schulen#Jahr') { |
| 265 | if ($_ eq '!') { |
| 266 | $i++; |
| 267 | next; |
| 268 | }; |
| 269 | foreach my $f (split(':', $_)) { |
| 270 | like($tokens->stream->pos($i)->to_string, |
| 271 | qr!\|xip/l:$f!, |
| 272 | 'Annotation (xip/l) is correct: ' . $f); |
| 273 | }; |
| 274 | $i++; |
| 275 | }; |
| 276 | |
| 277 | # New instantiation |
| 278 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 279 | |
| 280 | # Add XIP/Sentences |
Nils Diewald | 47c3ef3 | 2014-04-30 19:13:17 +0000 | [diff] [blame] | 281 | ok($tokens->add('XIP', 'Dependency'), 'Add XIP/Dependency'); |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 282 | |
| 283 | $stream = $tokens->stream; |
| 284 | like($stream->pos(1)->to_string, qr!\|>:xip/d:NMOD\$<i>3!, 'Dependency fine'); |
| 285 | like($stream->pos(3)->to_string, qr!\|<:xip/d:NMOD\$<i>1!, 'Dependency fine'); |
| 286 | like($stream->pos(3)->to_string, qr!\|<:xip/d:NMOD\$<i>2!, 'Dependency fine'); |
| 287 | like($stream->pos(4)->to_string, qr!\|>xip/d:VMAIN\$<i>4!, 'Dependency fine'); |
| 288 | like($stream->pos(4)->to_string, qr!\|<:xip/d:SUBJ\$<i>6!, 'Dependency fine'); |
| 289 | like($stream->pos(4)->to_string, qr!\|<:xip/d:VPREF\$<i>10!, 'Dependency fine'); |
| 290 | like($stream->pos(5)->to_string, qr!\|>:xip/d:DETERM\$<i>6!, 'Dependency fine'); |
| 291 | like($stream->pos(6)->to_string, qr!\|<:xip/d:DETERM\$<i>5!, 'Dependency fine'); |
| 292 | like($stream->pos(6)->to_string, qr!\|>:xip/d:SUBJ\$<i>4!, 'Dependency fine'); |
| 293 | like($stream->pos(6)->to_string, qr!\|<:xip/d:NMOD\$<i>8!, 'Dependency fine'); |
| 294 | like($stream->pos(7)->to_string, qr!\|>:xip/d:DETERM\$<i>8!, 'Dependency fine'); |
| 295 | like($stream->pos(8)->to_string, qr!\|<:xip/d:DETERM\$<i>7!, 'Dependency fine'); |
| 296 | like($stream->pos(8)->to_string, qr!\|>:xip/d:NMOD\$<i>6!, 'Dependency fine'); |
| 297 | like($stream->pos(8)->to_string, qr!\|<:xip/d:NMOD\$<i>9!, 'Dependency fine'); |
| 298 | like($stream->pos(9)->to_string, qr!\|>:xip/d:NMOD\$<i>8!, 'Dependency fine'); |
| 299 | like($stream->pos(10)->to_string, qr!\|>:xip/d:VPREF\$<i>4!, 'Dependency fine'); |
| 300 | like($stream->pos(11)->to_string, qr!\|>:xip/d:CONNECT\$<i>16!, 'Dependency fine'); |
| 301 | like($stream->pos(12)->to_string, qr!\|>:xip/d:DETERM\$<i>13!, 'Dependency fine'); |
| 302 | like($stream->pos(13)->to_string, qr!\|<:xip/d:DETERM\$<i>12!, 'Dependency fine'); |
| 303 | like($stream->pos(13)->to_string, qr!\|>:xip/d:SUBJ\$<i>16!, 'Dependency fine'); |
| 304 | like($stream->pos(14)->to_string, qr!\|>:xip/d:OBJ\$<i>16!, 'Dependency fine'); |
| 305 | like($stream->pos(15)->to_string, qr!\|>:xip/d:OBJ\$<i>16!, 'Dependency fine'); |
| 306 | like($stream->pos(16)->to_string, qr!\|<:xip/d:CONNECT\$<i>11!, 'Dependency fine'); |
| 307 | like($stream->pos(16)->to_string, qr!\|<:xip/d:SUBJ\$<i>13!, 'Dependency fine'); |
| 308 | like($stream->pos(16)->to_string, qr!\|<:xip/d:OBJ\$<i>14!, 'Dependency fine'); |
| 309 | like($stream->pos(16)->to_string, qr!\|<:xip/d:OBJ\$<i>15!, 'Dependency fine'); |
| 310 | like($stream->pos(16)->to_string, qr!\|>:xip/d:AUXIL\$<i>17!, 'Dependency fine'); |
| 311 | like($stream->pos(16)->to_string, qr!\|>xip/d:VMAIN\$<i>16!, 'Dependency fine'); |
| 312 | like($stream->pos(16)->to_string, qr!\|<xip/d:VMAIN\$<i>16!, 'Dependency fine'); |
| 313 | like($stream->pos(17)->to_string, qr!\|<:xip/d:AUXIL\$<i>16!, 'Dependency fine'); |
| 314 | |
Nils Diewald | 47c3ef3 | 2014-04-30 19:13:17 +0000 | [diff] [blame] | 315 | # New instantiation |
| 316 | ok($tokens = new_tokenizer->parse, 'New Tokenizer'); |
| 317 | |
| 318 | # Add XIP/Sentences |
| 319 | ok($tokens->add('XIP', 'Constituency'), 'Add XIP/Constituency'); |
| 320 | |
| 321 | $stream = $tokens->stream; |
| 322 | like($stream->pos(0)->to_string, qr!\|<>:xip/c:TOP#0-129\$<i>17!, 'Constituency fine'); |
| 323 | like($stream->pos(0)->to_string, qr!\|<>:xip/c:MC#0-129\$<i>17<b>1!, 'Constituency fine'); |
| 324 | like($stream->pos(0)->to_string, qr!\|<>:xip/c:PP#0-30\$<i>4<b>2!, 'Constituency fine'); |
| 325 | like($stream->pos(0)->to_string, qr!\|<>:xip/c:PREP#0-3\$<i>1!, 'Constituency fine'); |
| 326 | |
| 327 | like($stream->pos(1)->to_string, qr!\|<>:xip/c:NP#4-30\$<i>4<b>3!, 'Constituency fine'); |
| 328 | like($stream->pos(1)->to_string, qr!\|<>:xip/c:NPA#4-30\$<i>4<b>4!, 'Constituency fine'); |
| 329 | like($stream->pos(1)->to_string, qr!\|<>:xip/c:AP#4-11\$<i>2<b>5!, 'Constituency fine'); |
| 330 | like($stream->pos(1)->to_string, qr!\|<>:xip/c:ADJ#4-11\$<i>2<b>6!, 'Constituency fine'); |
| 331 | |
| 332 | like($stream->pos(2)->to_string, qr!\|<>:xip/c:AP#12-23\$<i>3<b>5!, 'Constituency fine'); |
| 333 | like($stream->pos(2)->to_string, qr!\|<>:xip/c:ADJ#12-23\$<i>3<b>6!, 'Constituency fine'); |
| 334 | |
| 335 | like($stream->pos(3)->to_string, qr!\|<>:xip/c:NOUN#24-30\$<i>4<b>5!, 'Constituency fine'); |
| 336 | |
| 337 | like($stream->pos(4)->to_string, qr!\|<>:xip/c:VERB#31-35\$<i>5<b>2!, 'Constituency fine'); |
| 338 | |
| 339 | like($stream->pos(5)->to_string, qr!\|<>:xip/c:NP#36-47\$<i>7<b>2!, 'Constituency fine'); |
| 340 | like($stream->pos(5)->to_string, qr!\|<>:xip/c:DET#36-39\$<i>6<b>3!, 'Constituency fine'); |
| 341 | |
| 342 | like($stream->pos(6)->to_string, qr!\|<>:xip/c:NPA#40-47\$<i>7<b>3!, 'Constituency fine'); |
| 343 | like($stream->pos(6)->to_string, qr!\|<>:xip/c:NOUN#40-47\$<i>7<b>4!, 'Constituency fine'); |
| 344 | |
| 345 | like($stream->pos(7)->to_string, qr!\|<>:xip/c:NP#48-63\$<i>9<b>2!, 'Constituency fine'); |
| 346 | like($stream->pos(7)->to_string, qr!\|<>:xip/c:DET#48-51\$<i>8<b>3!, 'Constituency fine'); |
| 347 | |
| 348 | like($stream->pos(8)->to_string, qr!\|<>:xip/c:NPA#52-63\$<i>9<b>3!, 'Constituency fine'); |
| 349 | like($stream->pos(8)->to_string, qr!\|<>:xip/c:NOUN#52-63\$<i>9<b>4!, 'Constituency fine'); |
| 350 | |
| 351 | like($stream->pos(9)->to_string, qr!\|<>:xip/c:NP#64-73\$<i>10<b>2!, 'Constituency fine'); |
| 352 | like($stream->pos(9)->to_string, qr!\|<>:xip/c:NPA#64-73\$<i>10<b>3!, 'Constituency fine'); |
| 353 | like($stream->pos(9)->to_string, qr!\|<>:xip/c:NOUN#64-73\$<i>10<b>4!, 'Constituency fine'); |
| 354 | |
| 355 | like($stream->pos(10)->to_string, qr!\|<>:xip/c:PTCL#74-77\$<i>11<b>2!, 'Constituency fine'); |
| 356 | |
| 357 | like($stream->pos(11)->to_string, qr!\|<>:xip/c:SC#79-128\$<i>18!, 'Constituency fine'); |
| 358 | like($stream->pos(11)->to_string, qr!\|<>:xip/c:CONJ#79-84\$<i>12<b>1!, 'Constituency fine'); |
| 359 | |
| 360 | like($stream->pos(12)->to_string, qr!\|<>:xip/c:NP#85-96\$<i>14<b>1!, 'Constituency fine'); |
| 361 | like($stream->pos(12)->to_string, qr!\|<>:xip/c:DET#85-88\$<i>13<b>2!, 'Constituency fine'); |
| 362 | |
| 363 | |
| 364 | like($stream->pos(13)->to_string, qr!\|<>:xip/c:NPA#89-96\$<i>14<b>2!, 'Constituency fine'); |
| 365 | like($stream->pos(13)->to_string, qr!\|<>:xip/c:NOUN#89-96\$<i>14<b>3!, 'Constituency fine'); |
| 366 | |
| 367 | like($stream->pos(14)->to_string, qr!\|<>:xip/c:NP#97-101\$<i>15<b>1!, 'Constituency fine'); |
| 368 | like($stream->pos(14)->to_string, qr!\|<>:xip/c:NPA#97-101\$<i>15<b>2!, 'Constituency fine'); |
| 369 | like($stream->pos(14)->to_string, qr!\|<>:xip/c:NOUN#97-101\$<i>15<b>3!, 'Constituency fine'); |
| 370 | |
| 371 | like($stream->pos(15)->to_string, qr!\|<>:xip/c:NP#102-111\$<i>16<b>1!, 'Constituency fine'); |
| 372 | like($stream->pos(15)->to_string, qr!\|<>:xip/c:NPA#102-111\$<i>16<b>2!, 'Constituency fine'); |
| 373 | like($stream->pos(15)->to_string, qr!\|<>:xip/c:NOUN#102-111\$<i>16<b>3!, 'Constituency fine'); |
| 374 | |
| 375 | like($stream->pos(16)->to_string, qr!\|<>:xip/c:VERB#112-123\$<i>17<b>1!, 'Constituency fine'); |
| 376 | |
| 377 | like($stream->pos(17)->to_string, qr!\|<>:xip/c:VERB#124-128\$<i>18<b>1!, 'Constituency fine'); |
| 378 | |
| 379 | # diag $stream->to_string; |
| 380 | |
Nils Diewald | 21a3e1a | 2014-04-28 18:48:16 +0000 | [diff] [blame] | 381 | |
| 382 | # ADJA ADJA NN VVFIN ART NN ART NN NE PTKVZ KOUS ART NN NN NN VVPP VAFIN |
| 383 | done_testing; |
| 384 | __END__ |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 385 | |
| 386 | |
| 387 | # Todo: CoreNLP/Constituency! |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 388 | |
| 389 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 390 | |
| 391 | |
| 392 | |
| 393 | # Connexor |
| 394 | push(@layers, ['Connexor', 'Morpho']); |
| 395 | push(@layers, ['Connexor', 'Syntax']); |
| 396 | push(@layers, ['Connexor', 'Phrase']); |
| 397 | push(@layers, ['Connexor', 'Sentences']); |
| 398 | |
| 399 | # TreeTagger |
| 400 | push(@layers, ['TreeTagger', 'Morpho']); |
| 401 | push(@layers, ['TreeTagger', 'Sentences']); |
| 402 | |
| 403 | # Mate |
| 404 | # push(@layers, ['Mate', 'Morpho']); |
| 405 | push(@layers, ['Mate', 'Dependency']); |
| 406 | |
| 407 | # XIP |
| 408 | push(@layers, ['XIP', 'Morpho']); |
| 409 | push(@layers, ['XIP', 'Constituency']); |
| 410 | push(@layers, ['XIP', 'Dependency']); |
| 411 | push(@layers, ['XIP', 'Sentences']); |
| 412 | |
| 413 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 414 | __END__ |