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; |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame^] | 7 | use KorAP::XML::Tokenizer; |
| 8 | use KorAP::XML::Krill; |
Akron | 3d47ca4 | 2016-01-25 20:55:55 +0100 | [diff] [blame] | 9 | use utf8; |
| 10 | |
| 11 | my $path = catdir(dirname(__FILE__), 'TEST', 'BSP', 1); |
| 12 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame^] | 13 | ok(my $doc = KorAP::XML::Krill->new( |
Akron | 3d47ca4 | 2016-01-25 20:55:55 +0100 | [diff] [blame] | 14 | path => $path . '/' |
| 15 | ), 'Create Document'); |
| 16 | |
| 17 | ok($doc->parse, 'Parse document'); |
| 18 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame^] | 19 | ok(my $tokens = KorAP::XML::Tokenizer->new( |
Akron | 3d47ca4 | 2016-01-25 20:55:55 +0100 | [diff] [blame] | 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 | my $data = $tokens->to_data->{data}; |
| 30 | |
| 31 | my $stream = $data->{stream}; |
| 32 | |
| 33 | is($stream->[0]->[0], '-:tokens$<i>51', 'Token number'); |
| 34 | is($stream->[0]->[1], '_0$<i>0<i>18', 'Position'); |
| 35 | is($stream->[0]->[2], 'i:sommerüberraschung', 'First term'); |
| 36 | is($stream->[0]->[3], 's:Sommerüberraschung', 'First term'); |
| 37 | is($stream->[-1]->[0], '_50$<i>359<i>364', 'Last position'); |
| 38 | is($stream->[-1]->[1], 'i:kevin', 'Last term'); |
| 39 | is($stream->[-1]->[2], 's:Kevin', 'Last term'); |
| 40 | |
| 41 | done_testing; |