Akron | 430ada3 | 2016-01-07 13:49:34 +0100 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | use utf8; |
| 5 | use Test::More skip_all => 'Not yet implemented'; |
| 6 | use Scalar::Util qw/weaken/; |
| 7 | use Data::Dumper; |
| 8 | |
| 9 | use_ok('KorAP::Document'); |
| 10 | |
| 11 | use File::Basename 'dirname'; |
| 12 | use File::Spec::Functions 'catdir'; |
| 13 | |
| 14 | my $path = catdir(dirname(__FILE__), 'corpus', 'doc', 'text'); |
| 15 | |
| 16 | ok(my $doc = KorAP::Document->new( |
| 17 | path => $path . '/' |
| 18 | ), 'Load Korap::Document'); |
| 19 | |
| 20 | like($doc->path, qr!$path/$!, 'Path'); |
| 21 | ok($doc->parse, 'Parse document'); |
| 22 | |
| 23 | ok($doc->primary->data, 'Primary data in existence'); |
| 24 | is($doc->primary->data_length, 129, 'Data length'); |
| 25 | |
| 26 | use_ok('KorAP::Tokenizer'); |
| 27 | |
| 28 | ok(my $tokens = KorAP::Tokenizer->new( |
| 29 | path => $doc->path, |
| 30 | doc => $doc, |
| 31 | foundry => 'OpenNLP', |
| 32 | layer => 'Tokens', |
| 33 | name => 'tokens' |
| 34 | ), 'New Tokenizer'); |
| 35 | |
| 36 | ok($tokens->parse, 'Parse'); |
| 37 | |
| 38 | ok($tokens->add('CoreNLP', 'Dependency'), 'Add Structure'); |
| 39 | |
| 40 | my $data = $tokens->to_data->{data}; |
| 41 | |
| 42 | |
| 43 | # diag Dumper $data; |
| 44 | |
| 45 | done_testing; |
| 46 | |
| 47 | __END__ |
| 48 | |
| 49 | |
| 50 | |
| 51 | like($data->{foundries}, qr!xip/morpho!, 'data'); |
| 52 | like($data->{layerInfos}, qr!xip/l=tokens!, 'data'); |
| 53 | like($data->{layerInfos}, qr!xip/p=tokens!, 'data'); |
| 54 | is($data->{stream}->[0]->[4], 'xip/l:zu', 'Lemma'); |
| 55 | is($data->{stream}->[0]->[5], 'xip/p:PREP', 'POS'); |
| 56 | |
| 57 | is($data->{stream}->[1]->[3], 'xip/l:letzt', 'Lemma'); |
| 58 | is($data->{stream}->[1]->[4], 'xip/p:ADJ', 'POS'); |
| 59 | |
| 60 | is($data->{stream}->[8]->[3], 'xip/l:\#Heim', 'Lemma (part)'); |
| 61 | is($data->{stream}->[8]->[4], 'xip/l:\#schulen', 'Lemma (part)'); |
| 62 | is($data->{stream}->[8]->[5], 'xip/l:schulen\#Heim', 'Lemma (part)'); |
| 63 | |
| 64 | is($data->{stream}->[-1]->[3], 'xip/l:werden', 'Lemma'); |
| 65 | is($data->{stream}->[-1]->[4], 'xip/p:VERB', 'POS'); |
| 66 | |