Nils Diewald | 79a355c | 2014-10-30 00:52:36 +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 Test::More; |
| 7 | use Data::Dumper; |
| 8 | use JSON::XS; |
| 9 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 10 | use Benchmark qw/:hireswallclock/; |
| 11 | |
| 12 | my $t = Benchmark->new; |
| 13 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 14 | use utf8; |
| 15 | use lib 'lib', '../lib'; |
| 16 | |
| 17 | use File::Basename 'dirname'; |
| 18 | use File::Spec::Functions 'catdir'; |
| 19 | |
| 20 | use_ok('KorAP::Document'); |
| 21 | |
| 22 | # GOE/AGA/03828 |
| 23 | my $path = catdir(dirname(__FILE__), 'GOE/AGA/03828'); |
Nils Diewald | a0e8d72 | 2014-11-01 01:18:25 +0000 | [diff] [blame] | 24 | # my $path = '/home/ndiewald/Repositories/korap/KorAP-sandbox/KorAP-lucene-indexer/t/GOE/AGA/03828'; |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 25 | |
| 26 | ok(my $doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
| 27 | ok($doc->parse, 'Parse document'); |
| 28 | |
| 29 | is($doc->text_sigle, 'GOE_AGA.03828', 'Correct text sigle'); |
| 30 | is($doc->doc_sigle, 'GOE_AGA', 'Correct document sigle'); |
| 31 | is($doc->corpus_sigle, 'GOE', 'Correct corpus sigle'); |
| 32 | |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 33 | is($doc->title, 'Autobiographische Einzelheiten', 'Title'); |
| 34 | is($doc->pub_place, 'München', 'PubPlace'); |
| 35 | is($doc->pub_date, '19820000', 'Creation Date'); |
| 36 | ok(!$doc->sub_title, 'SubTitle'); |
Nils Diewald | ebdc52d | 2014-10-31 17:29:23 +0000 | [diff] [blame] | 37 | is($doc->author, 'Goethe, Johann Wolfgang von', 'Author'); |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 38 | |
| 39 | is($doc->publisher, 'Verlag C. H. Beck', 'Publisher'); |
| 40 | ok(!$doc->editor, 'Publisher'); |
| 41 | is($doc->text_type, 'Autobiographie', 'Correct Text Type'); |
| 42 | ok(!$doc->text_type_art, 'Correct Text Type Art'); |
| 43 | ok(!$doc->text_type_ref, 'Correct Text Type Ref'); |
| 44 | ok(!$doc->text_column, 'Correct Text Column'); |
| 45 | ok(!$doc->text_domain, 'Correct Text Domain'); |
| 46 | is($doc->creation_date, '18200000', 'Creation Date'); |
| 47 | is($doc->license, 'QAO-NC', 'License'); |
| 48 | is($doc->pages, '529-547', 'Pages'); |
| 49 | ok(!$doc->file_edition_statement, 'File Ed Statement'); |
| 50 | ok(!$doc->bibl_edition_statement, 'Bibl Ed Statement'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 51 | is($doc->reference . "\n", <<'REF', 'Author'); |
| 52 | 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 |
| 53 | REF |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 54 | is($doc->language, 'de', 'Language'); |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 55 | |
| 56 | is($doc->corpus_title, 'Goethes Werke', 'Correct Corpus title'); |
| 57 | ok(!$doc->corpus_sub_title, 'Correct Corpus Sub title'); |
| 58 | is($doc->corpus_author, 'Goethe, Johann Wolfgang von', 'Correct Corpus author'); |
| 59 | is($doc->corpus_editor, 'Trunz, Erich', 'Correct Corpus editor'); |
| 60 | |
| 61 | is($doc->doc_title, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)', |
| 62 | 'Correct Doc title'); |
| 63 | ok(!$doc->doc_sub_title, 'Correct Doc Sub title'); |
| 64 | ok(!$doc->doc_author, 'Correct Doc author'); |
| 65 | ok(!$doc->doc_editor, 'Correct Doc editor'); |
| 66 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 67 | |
| 68 | # Tokenization |
| 69 | use_ok('KorAP::Tokenizer'); |
| 70 | |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 71 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 72 | my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/); |
| 73 | |
| 74 | # Get tokenization |
| 75 | my $tokens = KorAP::Tokenizer->new( |
| 76 | path => $doc->path, |
| 77 | doc => $doc, |
| 78 | foundry => $token_base_foundry, |
| 79 | layer => $token_base_layer, |
| 80 | name => 'tokens' |
| 81 | ); |
| 82 | ok($tokens, 'Token Object is fine'); |
| 83 | ok($tokens->parse, 'Token parsing is fine'); |
| 84 | |
| 85 | my $output = decode_json( $tokens->to_json ); |
| 86 | |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 87 | is(substr($output->{data}->{text}, 0, 100), 'Autobiographische einzelheiten Selbstschilderung (1) immer tätiger, nach innen und außen fortwirkend', 'Primary Data'); |
| 88 | is($output->{data}->{name}, 'tokens', 'tokenName'); |
| 89 | is($output->{data}->{tokenSource}, 'opennlp#tokens', 'tokenSource'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 90 | is($output->{version}, '0.02', 'version'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 91 | is($output->{data}->{foundries}, '', 'Foundries'); |
| 92 | is($output->{data}->{layerInfos}, '', 'layerInfos'); |
| 93 | is($output->{data}->{stream}->[0]->[3], 's:Autobiographische', 'data'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 94 | |
| 95 | is($output->{textSigle}, 'GOE_AGA.03828', 'Correct text sigle'); |
| 96 | is($output->{docSigle}, 'GOE_AGA', 'Correct document sigle'); |
| 97 | is($output->{corpusSigle}, 'GOE', 'Correct corpus sigle'); |
| 98 | |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 99 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 100 | is($output->{author}, 'Goethe, Johann Wolfgang von', 'Author'); |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 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'); |
| 107 | ok(!exists $output->{editor}, 'Editor'); |
| 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'); |
| 114 | is($output->{license}, 'QAO-NC', 'License'); |
| 115 | is($output->{pages}, '529-547', 'Pages'); |
| 116 | ok(!exists $output->{fileEditionStatement}, 'Correct Text Type'); |
| 117 | ok(!exists $output->{biblEditionStatement}, 'Correct Text Type'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 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 |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 121 | is($output->{language}, 'de', 'Language'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 122 | |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 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'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 132 | |
| 133 | ## Base |
| 134 | $tokens->add('Base', 'Sentences'); |
| 135 | $tokens->add('Base', 'Paragraphs'); |
| 136 | |
| 137 | $output = decode_json( $tokens->to_json ); |
| 138 | |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 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]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 142 | like($first_token, qr/s:Autobiographische/, 'data'); |
| 143 | like($first_token, qr/_0#0-17/, 'data'); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 144 | like($first_token, qr!<>:base/s:s#0-30\$<i>2<b>2!, 'data'); |
| 145 | like($first_token, qr!<>:base\/s:t#0-35199\$<i>5226<b>0!, 'data'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 146 | |
| 147 | ## OpenNLP |
| 148 | $tokens->add('OpenNLP', 'Sentences'); |
| 149 | |
| 150 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 151 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 152 | 'base base/paragraphs base/sentences opennlp opennlp/sentences', |
| 153 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 154 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/s=spans', 'layerInfos'); |
| 155 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 156 | like($first_token, qr!<>:opennlp/s:s#0-254\$<i>32!, 'data'); |
| 157 | |
| 158 | $tokens->add('OpenNLP', 'Morpho'); |
| 159 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 160 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 161 | 'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences', |
| 162 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 163 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans', 'layerInfos'); |
| 164 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 165 | like($first_token, qr!opennlp/p:ADJA!, 'data'); |
| 166 | |
| 167 | ## Treetagger |
| 168 | $tokens->add('TreeTagger', 'Sentences'); |
| 169 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 170 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 171 | 'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/sentences', |
| 172 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 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]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 175 | like($first_token, qr!<>:tt/s:s#0-179\$<i>21<b>2!, 'data'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 176 | |
| 177 | $tokens->add('TreeTagger', 'Morpho'); |
| 178 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 179 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 180 | 'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences', |
| 181 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 182 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos'); |
| 183 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 184 | like($first_token, qr!tt/l:autobiographisch\$<b>165!, 'data'); |
| 185 | like($first_token, qr!tt/p:ADJA\$<b>165!, 'data'); |
| 186 | like($first_token, qr!tt/l:Autobiographische\$<b>89!, 'data'); |
| 187 | like($first_token, qr!tt/p:NN\$<b>89!, 'data'); |
| 188 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 189 | ## CoreNLP |
| 190 | $tokens->add('CoreNLP', 'NamedEntities'); |
| 191 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 192 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 193 | 'base base/paragraphs base/sentences corenlp corenlp/namedentities opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences', |
| 194 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 195 | 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'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 196 | |
| 197 | diag "Missing test for NamedEntities"; |
| 198 | |
| 199 | # Problematic: |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 200 | # diag Dumper $output->{data}->{stream}->[180]; |
| 201 | # diag Dumper $output->{data}->{stream}->[341]; |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 202 | |
| 203 | $tokens->add('CoreNLP', 'Sentences'); |
| 204 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 205 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 206 | 'base base/paragraphs base/sentences corenlp corenlp/namedentities corenlp/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences', |
| 207 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 208 | 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'); |
| 209 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 210 | like($first_token, qr!<>:corenlp/s:s#0-254\$<i>32!, 'data'); |
| 211 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 212 | $tokens->add('CoreNLP', 'Morpho'); |
| 213 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 214 | like($output->{data}->{foundries}, qr!corenlp/morpho!, 'Foundries'); |
| 215 | like($output->{data}->{layerInfos}, qr!corenlp/p=tokens!, 'layerInfos'); |
| 216 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 217 | like($first_token, qr!corenlp/p:ADJA!, 'data'); |
| 218 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 219 | $tokens->add('CoreNLP', 'Constituency'); |
| 220 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 221 | like($output->{data}->{foundries}, qr!corenlp/constituency!, 'Foundries'); |
| 222 | like($output->{data}->{layerInfos}, qr!corenlp/c=spans!, 'layerInfos'); |
| 223 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 90a23f2 | 2014-10-31 02:16:14 +0000 | [diff] [blame] | 224 | like($first_token, qr!<>:corenlp/c:NP#0-17\$<i>1<b>6!, 'data'); |
| 225 | like($first_token, qr!<>:corenlp/c:CNP#0-17\$<i>1<b>7!, 'data'); |
| 226 | like($first_token, qr!<>:corenlp/c:NP#0-17\$<i>1<b>8!, 'data'); |
| 227 | like($first_token, qr!<>:corenlp/c:AP#0-17\$<i>1<b>9!, 'data'); |
| 228 | like($first_token, qr!<>:corenlp/c:PP#0-50\$<i>3<b>4!, 'data'); |
| 229 | like($first_token, qr!<>:corenlp/c:S#0-50\$<i>3<b>5!, 'data'); |
| 230 | like($first_token, qr!<>:corenlp/c:PP#0-58\$<i>5<b>2!, 'data'); |
| 231 | like($first_token, qr!<>:corenlp/c:S#0-58\$<i>5<b>3!, 'data'); |
| 232 | like($first_token, qr!<>:corenlp/c:ROOT#0-254\$<i>32<b>0!, 'data'); |
| 233 | like($first_token, qr!<>:corenlp/c:S#0-254\$<i>32<b>1!, 'data'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 234 | |
| 235 | ## Glemm |
| 236 | $tokens->add('Glemm', 'Morpho'); |
| 237 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 238 | like($output->{data}->{foundries}, qr!glemm/morpho!, 'Foundries'); |
| 239 | like($output->{data}->{layerInfos}, qr!glemm/l=tokens!, 'layerInfos'); |
| 240 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 241 | like($first_token, qr!glemm/l:__autobiographisch!, 'data'); |
| 242 | like($first_token, qr!glemm/l:\+_Auto!, 'data'); |
| 243 | like($first_token, qr!glemm/l:\+_biographisch!, 'data'); |
| 244 | like($first_token, qr!glemm/l:\+\+Biograph!, 'data'); |
| 245 | like($first_token, qr!glemm/l:\+\+-isch!, 'data'); |
| 246 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 247 | ## Connexor |
| 248 | $tokens->add('Connexor', 'Sentences'); |
| 249 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 250 | like($output->{data}->{foundries}, qr!connexor/sentences!, 'Foundries'); |
| 251 | like($output->{data}->{layerInfos}, qr!cnx/s=spans!, 'layerInfos'); |
| 252 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 253 | like($first_token, qr!<>:cnx/s:s#0-179\$<i>21<b>2!, 'data'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 254 | |
| 255 | $tokens->add('Connexor', 'Morpho'); |
| 256 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 257 | like($output->{data}->{foundries}, qr!connexor/morpho!, 'Foundries'); |
| 258 | like($output->{data}->{layerInfos}, qr!cnx/p=tokens!, 'layerInfos'); |
| 259 | like($output->{data}->{layerInfos}, qr!cnx/l=tokens!, 'layerInfos'); |
| 260 | like($output->{data}->{layerInfos}, qr!cnx/m=tokens!, 'layerInfos'); |
| 261 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 262 | like($first_token, qr!cnx/l:autobiografisch!, 'data'); |
| 263 | like($first_token, qr!cnx/p:A!, 'data'); |
| 264 | |
| 265 | $tokens->add('Connexor', 'Phrase'); |
| 266 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 267 | like($output->{data}->{foundries}, qr!connexor/phrase!, 'Foundries'); |
| 268 | like($output->{data}->{layerInfos}, qr!cnx/c=spans!, 'layerInfos'); |
| 269 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 270 | like($first_token, qr!<>:cnx/c:np#0-30\$<i>2!, 'data'); |
| 271 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 272 | $tokens->add('Connexor', 'Syntax'); |
| 273 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 274 | like($output->{data}->{foundries}, qr!connexor/syntax!, 'Foundries'); |
| 275 | like($output->{data}->{layerInfos}, qr!cnx/syn=tokens!, 'layerInfos'); |
| 276 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 277 | like($first_token, qr!cnx/syn:\@PREMOD!, 'data'); |
| 278 | |
| 279 | ## Mate |
| 280 | $tokens->add('Mate', 'Morpho'); |
| 281 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 282 | like($output->{data}->{foundries}, qr!mate/morpho!, 'Foundries'); |
| 283 | like($output->{data}->{layerInfos}, qr!mate/p=tokens!, 'layerInfos'); |
| 284 | like($output->{data}->{layerInfos}, qr!mate/l=tokens!, 'layerInfos'); |
| 285 | like($output->{data}->{layerInfos}, qr!mate/m=tokens!, 'layerInfos'); |
| 286 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 287 | like($first_token, qr!mate/l:autobiographisch!, 'data'); |
| 288 | like($first_token, qr!mate/p:NN!, 'data'); |
| 289 | like($first_token, qr!mate/m:case:nom!, 'data'); |
| 290 | like($first_token, qr!mate/m:number:pl!, 'data'); |
| 291 | like($first_token, qr!mate/m:gender:\*!, 'data'); |
| 292 | |
| 293 | |
Nils Diewald | 90a23f2 | 2014-10-31 02:16:14 +0000 | [diff] [blame] | 294 | diag "No test for mate dependency"; |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 295 | |
| 296 | ## XIP |
| 297 | $tokens->add('XIP', 'Sentences'); |
| 298 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 299 | like($output->{data}->{foundries}, qr!xip/sentences!, 'Foundries'); |
| 300 | like($output->{data}->{layerInfos}, qr!xip/s=spans!, 'layerInfos'); |
| 301 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 302 | like($first_token, qr!<>:xip/s:s#0-179\$<i>21!, 'data'); |
| 303 | |
| 304 | $tokens->add('XIP', 'Morpho'); |
| 305 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 306 | like($output->{data}->{foundries}, qr!xip/morpho!, 'Foundries'); |
| 307 | like($output->{data}->{layerInfos}, qr!xip/l=tokens!, 'layerInfos'); |
| 308 | like($output->{data}->{layerInfos}, qr!xip/p=tokens!, 'layerInfos'); |
| 309 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 310 | like($first_token, qr!<>:xip/s:s#0-179\$<i>21!, 'data'); |
| 311 | |
| 312 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 313 | $tokens->add('XIP', 'Constituency'); |
| 314 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 315 | like($output->{data}->{foundries}, qr!xip/constituency!, 'Foundries'); |
| 316 | like($output->{data}->{layerInfos}, qr!xip/c=spans!, 'layerInfos'); |
| 317 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 318 | like($first_token, qr!<>:xip/c:NP#0-17\$<i>1<b>1!, 'data'); |
| 319 | like($first_token, qr!<>:xip/c:AP#0-17\$<i>1<b>2!, 'data'); |
| 320 | like($first_token, qr!<>:xip/c:ADJ#0-17\$<i>1<b>3!, 'data'); |
| 321 | like($first_token, qr!<>:xip/c:TOP#0-179\$<i>21<b>0!, 'data'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 322 | |
Nils Diewald | 90a23f2 | 2014-10-31 02:16:14 +0000 | [diff] [blame] | 323 | diag "No test for xip dependency"; |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 324 | |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 325 | # diag Dumper $output->{data}->{stream}->[0]; |
Nils Diewald | 90a23f2 | 2014-10-31 02:16:14 +0000 | [diff] [blame] | 326 | |
| 327 | # print timestr(timediff(Benchmark->new, $t)); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 328 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 329 | done_testing; |
| 330 | __END__ |