Akron | 3d47ca4 | 2016-01-25 20:55:55 +0100 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
| 4 | use File::Basename 'dirname'; |
| 5 | use File::Spec::Functions 'catdir'; |
| 6 | use Data::Dumper; |
| 7 | use KorAP::Tokenizer; |
| 8 | use KorAP::Document; |
| 9 | use utf8; |
| 10 | |
| 11 | my $path = catdir(dirname(__FILE__), 'TEST', 'BSP', 1); |
| 12 | |
| 13 | ok(my $doc = KorAP::Document->new( |
| 14 | path => $path . '/' |
| 15 | ), 'Create Document'); |
| 16 | |
| 17 | ok($doc->parse, 'Parse document'); |
| 18 | |
| 19 | ok(my $tokens = KorAP::Tokenizer->new( |
| 20 | path => $doc->path, |
| 21 | doc => $doc, |
| 22 | foundry => 'Sgbr', |
| 23 | layer => 'Lemma', |
| 24 | name => 'tokens' |
| 25 | ), 'Create tokens based on lemmata'); |
| 26 | |
| 27 | ok($tokens->parse, 'Parse tokenization based on lemmata'); |
| 28 | |
| 29 | ok($tokens->add('Schreibgebrauch', 'Morpho'), 'Add Structure'); |
| 30 | |
| 31 | my $data = $tokens->to_data->{data}; |
| 32 | |
| 33 | my $stream = $data->{stream}; |
| 34 | |
| 35 | is($stream->[0]->[0], '-:tokens$<i>51', 'Token number'); |
| 36 | is($stream->[0]->[1], '_0$<i>0<i>18', 'Position'); |
| 37 | is($stream->[0]->[2], 'i:sommerüberraschung', 'First term'); |
| 38 | is($stream->[0]->[3], 's:Sommerüberraschung', 'First term'); |
| 39 | is($stream->[0]->[4], 'sgbr/p:NN', 'First term POS'); |
| 40 | |
| 41 | is($stream->[1]->[3], 'sgbr/p:PPER', 'First term POS'); |
| 42 | is($stream->[-1]->[3], 'sgbr/p:NE', 'Last term POS'); |
| 43 | |
| 44 | done_testing; |