blob: 8387ec78e38f6133828a5ae8830f241fe3864dd8 [file] [log] [blame]
Akron6989df72016-01-07 13:49:34 +01001#!/usr/bin/env perl
2use strict;
3use warnings;
4use utf8;
5use Test::More skip_all => 'Not yet implemented';
6use Scalar::Util qw/weaken/;
7use Data::Dumper;
8
9use_ok('KorAP::Document');
10
11use File::Basename 'dirname';
12use File::Spec::Functions 'catdir';
13
Akron601fc152016-01-16 14:51:07 +010014my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001');
Akron6989df72016-01-07 13:49:34 +010015
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('CoreNLP', 'Dependency'), 'Add Structure');
39
40my $data = $tokens->to_data->{data};
41
42
43# diag Dumper $data;
44
45done_testing;
46
47__END__
48
49
50
51like($data->{foundries}, qr!xip/morpho!, 'data');
52like($data->{layerInfos}, qr!xip/l=tokens!, 'data');
53like($data->{layerInfos}, qr!xip/p=tokens!, 'data');
54is($data->{stream}->[0]->[4], 'xip/l:zu', 'Lemma');
55is($data->{stream}->[0]->[5], 'xip/p:PREP', 'POS');
56
57is($data->{stream}->[1]->[3], 'xip/l:letzt', 'Lemma');
58is($data->{stream}->[1]->[4], 'xip/p:ADJ', 'POS');
59
60is($data->{stream}->[8]->[3], 'xip/l:\#Heim', 'Lemma (part)');
61is($data->{stream}->[8]->[4], 'xip/l:\#schulen', 'Lemma (part)');
62is($data->{stream}->[8]->[5], 'xip/l:schulen\#Heim', 'Lemma (part)');
63
64is($data->{stream}->[-1]->[3], 'xip/l:werden', 'Lemma');
65is($data->{stream}->[-1]->[4], 'xip/p:VERB', 'POS');
66