Akron | d1eed34 | 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', 'Lemma'), 'Add Structure'); |
| 30 | |
| 31 | my $data = $tokens->to_data->{data}; |
| 32 | |
| 33 | my $stream = $data->{stream}; |
| 34 | is($stream->[0]->[0], '-:tokens$<i>51', 'Token number'); |
| 35 | is($stream->[0]->[1], '_0$<i>0<i>18', 'Position'); |
| 36 | is($stream->[0]->[2], 'i:sommerüberraschung', 'First term'); |
| 37 | is($stream->[0]->[3], 's:Sommerüberraschung', 'First term'); |
| 38 | is($stream->[0]->[4], 'sgbr/l:Sommerüberraschung', 'First term'); |
| 39 | ok(!defined $stream->[0]->[5], 'First term'); |
| 40 | |
| 41 | is($stream->[1]->[0], '_1$<i>19<i>21', 'Position'); |
| 42 | is($stream->[1]->[1], 'i:es', 'Second term'); |
| 43 | is($stream->[1]->[2], 's:Es', 'Second term'); |
| 44 | is($stream->[1]->[3], 'sgbr/l:es', 'Second term'); |
| 45 | is($stream->[1]->[4], 'sgbr/lv:er', 'Second term'); |
| 46 | is($stream->[1]->[5], 'sgbr/lv:sie', 'Second term'); |
| 47 | |
| 48 | is($stream->[16]->[0], '_16$<i>107<i>115', 'Position'); |
| 49 | is($stream->[16]->[1], 'i:guenther', '16th term'); |
| 50 | is($stream->[16]->[2], 's:Guenther', '16th term'); |
| 51 | is($stream->[16]->[3], 'sgbr/l:Günther', '16th term'); |
| 52 | is($stream->[16]->[4], 'sgbr/lv:Günter', '16th term'); |
| 53 | |
| 54 | is($stream->[-1]->[0], '_50$<i>359<i>364', 'Position'); |
| 55 | is($stream->[-1]->[1], 'i:kevin', 'Last term'); |
| 56 | is($stream->[-1]->[2], 's:Kevin', 'Last term'); |
| 57 | is($stream->[-1]->[3], 'sgbr/l:Kevin', 'Last term'); |
| 58 | |
| 59 | done_testing; |