blob: f2dcfa99c7c4163aa4e43b29e27a82e4c5ae76e5 [file] [log] [blame]
Akron1622dd92015-12-09 22:34:26 +01001#!/usr/bin/env perl
2use strict;
3use warnings;
4use utf8;
5use Test::More;
6use Scalar::Util qw/weaken/;
Akrond69836b2015-12-10 00:40:20 +01007use Data::Dumper;
Akron1622dd92015-12-09 22:34:26 +01008
9use_ok('KorAP::Document');
10
11use File::Basename 'dirname';
12use File::Spec::Functions 'catdir';
13
14my $path = catdir(dirname(__FILE__), 'corpus', 'doc', 'text');
15
16ok(my $doc = KorAP::Document->new(
17 path => $path . '/'
18), 'Load Korap::Document');
19
20like($doc->path, qr!$path/$!, 'Path');
21ok($doc->parse, 'Parse document');
22
23ok($doc->primary->data, 'Primary data in existence');
24is($doc->primary->data_length, 129, 'Data length');
25
26use_ok('KorAP::Tokenizer');
27
28ok(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
36ok($tokens->parse, 'Parse');
37
38ok($tokens->add('Base', 'Paragraphs'), 'Add Structure');
39
Akrond69836b2015-12-10 00:40:20 +010040my $data = $tokens->to_data->{data};
41
42like($data->{foundries}, qr!base/paragraphs!, 'data');
43is($data->{stream}->[0]->[0], '-:base/paragraphs$<i>1', 'Number of paragraphs');
44is($data->{stream}->[0]->[1], '-:tokens$<i>18', 'Number of tokens');
45is($data->{stream}->[0]->[2], '<>:base/s:p$<b>64<i>0<i>129<i>17<b>1', 'Paragraph');
46is($data->{stream}->[0]->[3], '_0$<i>0<i>3', 'Position');
Akron1622dd92015-12-09 22:34:26 +010047
48done_testing;
49
50__END__