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 | |
Nils Diewald | 1920571 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 56 | is($doc->corpus_title, 'Goethe-Korpus', 'Correct Corpus title'); |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 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 | # Tokenization |
| 68 | use_ok('KorAP::Tokenizer'); |
| 69 | |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 70 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 71 | my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/); |
| 72 | |
| 73 | # Get tokenization |
| 74 | my $tokens = KorAP::Tokenizer->new( |
| 75 | path => $doc->path, |
| 76 | doc => $doc, |
| 77 | foundry => $token_base_foundry, |
| 78 | layer => $token_base_layer, |
| 79 | name => 'tokens' |
| 80 | ); |
| 81 | ok($tokens, 'Token Object is fine'); |
| 82 | ok($tokens->parse, 'Token parsing is fine'); |
| 83 | |
| 84 | my $output = decode_json( $tokens->to_json ); |
| 85 | |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 86 | is(substr($output->{data}->{text}, 0, 100), 'Autobiographische einzelheiten Selbstschilderung (1) immer tätiger, nach innen und außen fortwirkend', 'Primary Data'); |
| 87 | is($output->{data}->{name}, 'tokens', 'tokenName'); |
| 88 | is($output->{data}->{tokenSource}, 'opennlp#tokens', 'tokenSource'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 89 | is($output->{version}, '0.02', 'version'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 90 | is($output->{data}->{foundries}, '', 'Foundries'); |
| 91 | is($output->{data}->{layerInfos}, '', 'layerInfos'); |
| 92 | is($output->{data}->{stream}->[0]->[3], 's:Autobiographische', 'data'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 93 | |
| 94 | is($output->{textSigle}, 'GOE_AGA.03828', 'Correct text sigle'); |
| 95 | is($output->{docSigle}, 'GOE_AGA', 'Correct document sigle'); |
| 96 | is($output->{corpusSigle}, 'GOE', 'Correct corpus sigle'); |
| 97 | |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 98 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 99 | is($output->{author}, 'Goethe, Johann Wolfgang von', 'Author'); |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 100 | is($output->{pubPlace}, 'München', 'PubPlace'); |
| 101 | is($output->{pubDate}, '19820000', 'Creation Date'); |
| 102 | is($output->{title}, 'Autobiographische Einzelheiten', 'Title'); |
| 103 | ok(!exists $output->{subTitle}, 'subTitle'); |
| 104 | |
| 105 | is($output->{publisher}, 'Verlag C. H. Beck', 'Publisher'); |
| 106 | ok(!exists $output->{editor}, 'Editor'); |
| 107 | is($output->{textType}, 'Autobiographie', 'Correct Text Type'); |
| 108 | ok(!exists $output->{textTypeArt}, 'Correct Text Type'); |
| 109 | ok(!exists $output->{textTypeRef}, 'Correct Text Type'); |
| 110 | ok(!exists $output->{textColumn}, 'Correct Text Type'); |
| 111 | ok(!exists $output->{textDomain}, 'Correct Text Type'); |
| 112 | is($output->{creationDate}, '18200000', 'Creation Date'); |
| 113 | is($output->{license}, 'QAO-NC', 'License'); |
| 114 | is($output->{pages}, '529-547', 'Pages'); |
| 115 | ok(!exists $output->{fileEditionStatement}, 'Correct Text Type'); |
| 116 | ok(!exists $output->{biblEditionStatement}, 'Correct Text Type'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 117 | is($output->{reference} . "\n", <<'REF', 'Author'); |
| 118 | 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 |
| 119 | REF |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 120 | is($output->{language}, 'de', 'Language'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 121 | |
Nils Diewald | 1920571 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 122 | is($output->{corpusTitle}, 'Goethe-Korpus', 'Correct Corpus title'); |
Nils Diewald | c95607a | 2014-11-03 21:04:05 +0000 | [diff] [blame] | 123 | ok(!exists $output->{corpusSubTitle}, 'Correct Text Type'); |
| 124 | is($output->{corpusAuthor}, 'Goethe, Johann Wolfgang von', 'Correct Corpus title'); |
| 125 | is($output->{corpusEditor}, 'Trunz, Erich', 'Editor'); |
| 126 | |
| 127 | is($output->{docTitle}, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)', 'Correct Corpus title'); |
| 128 | ok(!exists $output->{docSubTitle}, 'Correct Text Type'); |
| 129 | ok(!exists $output->{docAuthor}, 'Correct Text Type'); |
| 130 | ok(!exists $output->{docEditor}, 'Correct Text Type'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 131 | |
| 132 | ## Base |
| 133 | $tokens->add('Base', 'Sentences'); |
| 134 | $tokens->add('Base', 'Paragraphs'); |
| 135 | |
| 136 | $output = decode_json( $tokens->to_json ); |
| 137 | |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 138 | is($output->{data}->{foundries}, 'base base/paragraphs base/sentences', 'Foundries'); |
| 139 | is($output->{data}->{layerInfos}, 'base/s=spans', 'layerInfos'); |
| 140 | my $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 141 | like($first_token, qr/s:Autobiographische/, 'data'); |
| 142 | like($first_token, qr/_0#0-17/, 'data'); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 143 | like($first_token, qr!<>:base/s:s#0-30\$<i>2<b>2!, 'data'); |
| 144 | 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] | 145 | |
| 146 | ## OpenNLP |
| 147 | $tokens->add('OpenNLP', 'Sentences'); |
| 148 | |
| 149 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 150 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 151 | 'base base/paragraphs base/sentences opennlp opennlp/sentences', |
| 152 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 153 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/s=spans', 'layerInfos'); |
| 154 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 155 | like($first_token, qr!<>:opennlp/s:s#0-254\$<i>32!, 'data'); |
| 156 | |
| 157 | $tokens->add('OpenNLP', 'Morpho'); |
| 158 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 159 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 160 | 'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences', |
| 161 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 162 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans', 'layerInfos'); |
| 163 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 164 | like($first_token, qr!opennlp/p:ADJA!, 'data'); |
| 165 | |
| 166 | ## Treetagger |
| 167 | $tokens->add('TreeTagger', 'Sentences'); |
| 168 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 169 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 170 | 'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/sentences', |
| 171 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 172 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/s=spans', 'layerInfos'); |
| 173 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 174 | 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] | 175 | |
| 176 | $tokens->add('TreeTagger', 'Morpho'); |
| 177 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 178 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 179 | 'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences', |
| 180 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 181 | is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos'); |
| 182 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 183 | like($first_token, qr!tt/l:autobiographisch\$<b>165!, 'data'); |
| 184 | like($first_token, qr!tt/p:ADJA\$<b>165!, 'data'); |
| 185 | like($first_token, qr!tt/l:Autobiographische\$<b>89!, 'data'); |
| 186 | like($first_token, qr!tt/p:NN\$<b>89!, 'data'); |
| 187 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 188 | ## CoreNLP |
| 189 | $tokens->add('CoreNLP', 'NamedEntities'); |
| 190 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 191 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 192 | 'base base/paragraphs base/sentences corenlp corenlp/namedentities opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences', |
| 193 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 194 | 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] | 195 | |
| 196 | diag "Missing test for NamedEntities"; |
| 197 | |
| 198 | # Problematic: |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 199 | # diag Dumper $output->{data}->{stream}->[180]; |
| 200 | # diag Dumper $output->{data}->{stream}->[341]; |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 201 | |
| 202 | $tokens->add('CoreNLP', 'Sentences'); |
| 203 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 204 | is($output->{data}->{foundries}, |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 205 | 'base base/paragraphs base/sentences corenlp corenlp/namedentities corenlp/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences', |
| 206 | 'Foundries'); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 207 | 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'); |
| 208 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 209 | like($first_token, qr!<>:corenlp/s:s#0-254\$<i>32!, 'data'); |
| 210 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 211 | $tokens->add('CoreNLP', 'Morpho'); |
| 212 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 213 | like($output->{data}->{foundries}, qr!corenlp/morpho!, 'Foundries'); |
| 214 | like($output->{data}->{layerInfos}, qr!corenlp/p=tokens!, 'layerInfos'); |
| 215 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 216 | like($first_token, qr!corenlp/p:ADJA!, 'data'); |
| 217 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 218 | $tokens->add('CoreNLP', 'Constituency'); |
| 219 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 220 | like($output->{data}->{foundries}, qr!corenlp/constituency!, 'Foundries'); |
| 221 | like($output->{data}->{layerInfos}, qr!corenlp/c=spans!, 'layerInfos'); |
| 222 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 90a23f2 | 2014-10-31 02:16:14 +0000 | [diff] [blame] | 223 | like($first_token, qr!<>:corenlp/c:NP#0-17\$<i>1<b>6!, 'data'); |
| 224 | like($first_token, qr!<>:corenlp/c:CNP#0-17\$<i>1<b>7!, 'data'); |
| 225 | like($first_token, qr!<>:corenlp/c:NP#0-17\$<i>1<b>8!, 'data'); |
| 226 | like($first_token, qr!<>:corenlp/c:AP#0-17\$<i>1<b>9!, 'data'); |
| 227 | like($first_token, qr!<>:corenlp/c:PP#0-50\$<i>3<b>4!, 'data'); |
| 228 | like($first_token, qr!<>:corenlp/c:S#0-50\$<i>3<b>5!, 'data'); |
| 229 | like($first_token, qr!<>:corenlp/c:PP#0-58\$<i>5<b>2!, 'data'); |
| 230 | like($first_token, qr!<>:corenlp/c:S#0-58\$<i>5<b>3!, 'data'); |
| 231 | like($first_token, qr!<>:corenlp/c:ROOT#0-254\$<i>32<b>0!, 'data'); |
| 232 | 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] | 233 | |
| 234 | ## Glemm |
| 235 | $tokens->add('Glemm', 'Morpho'); |
| 236 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 237 | like($output->{data}->{foundries}, qr!glemm/morpho!, 'Foundries'); |
| 238 | like($output->{data}->{layerInfos}, qr!glemm/l=tokens!, 'layerInfos'); |
| 239 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 240 | like($first_token, qr!glemm/l:__autobiographisch!, 'data'); |
| 241 | like($first_token, qr!glemm/l:\+_Auto!, 'data'); |
| 242 | like($first_token, qr!glemm/l:\+_biographisch!, 'data'); |
| 243 | like($first_token, qr!glemm/l:\+\+Biograph!, 'data'); |
| 244 | like($first_token, qr!glemm/l:\+\+-isch!, 'data'); |
| 245 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 246 | ## Connexor |
| 247 | $tokens->add('Connexor', 'Sentences'); |
| 248 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 249 | like($output->{data}->{foundries}, qr!connexor/sentences!, 'Foundries'); |
| 250 | like($output->{data}->{layerInfos}, qr!cnx/s=spans!, 'layerInfos'); |
| 251 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 0d76734 | 2015-06-17 20:34:24 +0000 | [diff] [blame] | 252 | like($first_token, qr!<>:cnx/s:s#0-179\$<i>21<b>0!, 'data'); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 253 | |
| 254 | $tokens->add('Connexor', 'Morpho'); |
| 255 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 256 | like($output->{data}->{foundries}, qr!connexor/morpho!, 'Foundries'); |
| 257 | like($output->{data}->{layerInfos}, qr!cnx/p=tokens!, 'layerInfos'); |
| 258 | like($output->{data}->{layerInfos}, qr!cnx/l=tokens!, 'layerInfos'); |
| 259 | like($output->{data}->{layerInfos}, qr!cnx/m=tokens!, 'layerInfos'); |
| 260 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 261 | like($first_token, qr!cnx/l:autobiografisch!, 'data'); |
| 262 | like($first_token, qr!cnx/p:A!, 'data'); |
| 263 | |
| 264 | $tokens->add('Connexor', 'Phrase'); |
| 265 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 266 | like($output->{data}->{foundries}, qr!connexor/phrase!, 'Foundries'); |
| 267 | like($output->{data}->{layerInfos}, qr!cnx/c=spans!, 'layerInfos'); |
| 268 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 269 | like($first_token, qr!<>:cnx/c:np#0-30\$<i>2!, 'data'); |
| 270 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 271 | $tokens->add('Connexor', 'Syntax'); |
| 272 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 273 | like($output->{data}->{foundries}, qr!connexor/syntax!, 'Foundries'); |
| 274 | like($output->{data}->{layerInfos}, qr!cnx/syn=tokens!, 'layerInfos'); |
| 275 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 276 | like($first_token, qr!cnx/syn:\@PREMOD!, 'data'); |
| 277 | |
| 278 | ## Mate |
| 279 | $tokens->add('Mate', 'Morpho'); |
| 280 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 281 | like($output->{data}->{foundries}, qr!mate/morpho!, 'Foundries'); |
| 282 | like($output->{data}->{layerInfos}, qr!mate/p=tokens!, 'layerInfos'); |
| 283 | like($output->{data}->{layerInfos}, qr!mate/l=tokens!, 'layerInfos'); |
| 284 | like($output->{data}->{layerInfos}, qr!mate/m=tokens!, 'layerInfos'); |
| 285 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 286 | like($first_token, qr!mate/l:autobiographisch!, 'data'); |
| 287 | like($first_token, qr!mate/p:NN!, 'data'); |
| 288 | like($first_token, qr!mate/m:case:nom!, 'data'); |
| 289 | like($first_token, qr!mate/m:number:pl!, 'data'); |
| 290 | like($first_token, qr!mate/m:gender:\*!, 'data'); |
| 291 | |
| 292 | |
Nils Diewald | 90a23f2 | 2014-10-31 02:16:14 +0000 | [diff] [blame] | 293 | diag "No test for mate dependency"; |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 294 | |
| 295 | ## XIP |
| 296 | $tokens->add('XIP', 'Sentences'); |
| 297 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 298 | like($output->{data}->{foundries}, qr!xip/sentences!, 'Foundries'); |
| 299 | like($output->{data}->{layerInfos}, qr!xip/s=spans!, 'layerInfos'); |
| 300 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 301 | like($first_token, qr!<>:xip/s:s#0-179\$<i>21!, 'data'); |
| 302 | |
| 303 | $tokens->add('XIP', 'Morpho'); |
| 304 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 305 | like($output->{data}->{foundries}, qr!xip/morpho!, 'Foundries'); |
| 306 | like($output->{data}->{layerInfos}, qr!xip/l=tokens!, 'layerInfos'); |
| 307 | like($output->{data}->{layerInfos}, qr!xip/p=tokens!, 'layerInfos'); |
| 308 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 309 | like($first_token, qr!<>:xip/s:s#0-179\$<i>21!, 'data'); |
| 310 | |
| 311 | |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 312 | $tokens->add('XIP', 'Constituency'); |
| 313 | $output = decode_json( $tokens->to_json ); |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 314 | like($output->{data}->{foundries}, qr!xip/constituency!, 'Foundries'); |
| 315 | like($output->{data}->{layerInfos}, qr!xip/c=spans!, 'layerInfos'); |
| 316 | $first_token = join('||', @{$output->{data}->{stream}->[0]}); |
Nils Diewald | a5565f6 | 2014-10-30 23:20:58 +0000 | [diff] [blame] | 317 | like($first_token, qr!<>:xip/c:NP#0-17\$<i>1<b>1!, 'data'); |
| 318 | like($first_token, qr!<>:xip/c:AP#0-17\$<i>1<b>2!, 'data'); |
| 319 | like($first_token, qr!<>:xip/c:ADJ#0-17\$<i>1<b>3!, 'data'); |
| 320 | 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] | 321 | |
Nils Diewald | 90a23f2 | 2014-10-31 02:16:14 +0000 | [diff] [blame] | 322 | diag "No test for xip dependency"; |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 323 | |
Nils Diewald | df1733f | 2014-11-01 17:25:12 +0000 | [diff] [blame] | 324 | # diag Dumper $output->{data}->{stream}->[0]; |
Nils Diewald | 90a23f2 | 2014-10-31 02:16:14 +0000 | [diff] [blame] | 325 | |
| 326 | # print timestr(timediff(Benchmark->new, $t)); |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 327 | |
Nils Diewald | 79a355c | 2014-10-30 00:52:36 +0000 | [diff] [blame] | 328 | done_testing; |
| 329 | __END__ |