blob: e87a1d7d8b4c26f97c6edc7926fdd1b11bde94af [file] [log] [blame]
Akron3d47ca42016-01-25 20:55:55 +01001use strict;
2use warnings;
3use Test::More;
4use File::Basename 'dirname';
5use File::Spec::Functions 'catdir';
6use Data::Dumper;
Akrone4c2e412016-01-28 15:10:50 +01007use KorAP::XML::Tokenizer;
8use KorAP::XML::Krill;
Akron3d47ca42016-01-25 20:55:55 +01009use utf8;
10
11my $path = catdir(dirname(__FILE__), 'TEST', 'BSP', 1);
12
Akrone4c2e412016-01-28 15:10:50 +010013ok(my $doc = KorAP::XML::Krill->new(
Akron3d47ca42016-01-25 20:55:55 +010014 path => $path . '/'
15), 'Create Document');
16
17ok($doc->parse, 'Parse document');
18
Akrone4c2e412016-01-28 15:10:50 +010019ok(my $tokens = KorAP::XML::Tokenizer->new(
Akron3d47ca42016-01-25 20:55:55 +010020 path => $doc->path,
21 doc => $doc,
22 foundry => 'Sgbr',
23 layer => 'Lemma',
24 name => 'tokens'
25), 'Create tokens based on lemmata');
26
27ok($tokens->parse, 'Parse tokenization based on lemmata');
28
Akron93d620e2016-02-05 19:40:05 +010029ok($tokens->add('Sgbr', 'Morpho'), 'Add Structure');
Akron3d47ca42016-01-25 20:55:55 +010030
31my $data = $tokens->to_data->{data};
32
33my $stream = $data->{stream};
34
35is($stream->[0]->[0], '-:tokens$<i>51', 'Token number');
36is($stream->[0]->[1], '_0$<i>0<i>18', 'Position');
37is($stream->[0]->[2], 'i:sommerüberraschung', 'First term');
38is($stream->[0]->[3], 's:Sommerüberraschung', 'First term');
39is($stream->[0]->[4], 'sgbr/p:NN', 'First term POS');
40
41is($stream->[1]->[3], 'sgbr/p:PPER', 'First term POS');
42is($stream->[-1]->[3], 'sgbr/p:NE', 'Last term POS');
43
Akron8c84aa52016-02-13 21:26:54 +010044
45ok($tokens->add('Sgbr', 'Lemma'), 'Add Structure');
46
47$data = $tokens->to_data->{data};
48$stream = $data->{stream};
49
50is($stream->[-1]->[0], '_50$<i>359<i>364', 'Token number');
51is($stream->[-1]->[1], 'i:kevin', 'Position');
52is($stream->[-1]->[2], 's:Kevin', 'Last term');
53is($stream->[-1]->[3], 'sgbr/l:Kevin', 'Last term');
54is($stream->[-1]->[4], 'sgbr/p:NE', 'Last term');
55ok(!defined $stream->[-1]->[5], 'Last term');
56
Akron3d47ca42016-01-25 20:55:55 +010057done_testing;