blob: f6293c282fd4e3b0ec14cd69a1d03ae8765ed60b [file] [log] [blame]
Akrond3a0bad2016-02-26 14:07:58 +01001use strict;
2use warnings;
3use Test::More;
4use Data::Dumper;
5use JSON::XS;
6
7use Benchmark qw/:hireswallclock/;
8
9my $t = Benchmark->new;
10
11use utf8;
12use lib 'lib', '../lib';
13
14use File::Basename 'dirname';
15use File::Spec::Functions 'catdir';
16
17use_ok('KorAP::XML::Krill');
18
19# GOE/AGA/03828
20my $path = catdir(dirname(__FILE__), '../corpus/WPD/00001');
Akrond3a0bad2016-02-26 14:07:58 +010021
22ok(my $doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
23ok($doc->parse, 'Parse document');
24
Akron1cd5b872016-03-22 00:23:46 +010025is($doc->text_sigle, 'WPD/AAA/00001', 'Correct text sigle');
26is($doc->doc_sigle, 'WPD/AAA', 'Correct document sigle');
Akrond3a0bad2016-02-26 14:07:58 +010027is($doc->corpus_sigle, 'WPD', 'Correct corpus sigle');
28
Akron35db6e32016-03-17 22:42:22 +010029my $meta = $doc->meta;
30is($meta->{title}, 'A', 'Title');
31is($meta->{pub_place}, 'URL:http://de.wikipedia.org', 'PubPlace');
32is($meta->{pub_date}, '20050328', 'Creation Date');
33ok(!$meta->{sub_title}, 'SubTitle');
34is($meta->{author}, 'Ruru; Jens.Ol; Aglarech; u.a.', 'Author');
Akrond3a0bad2016-02-26 14:07:58 +010035
Akron35db6e32016-03-17 22:42:22 +010036ok(!$meta->{doc_title}, 'Correct Doc title');
37ok(!$meta->{doc_sub_title}, 'Correct Doc Sub title');
38ok(!$meta->{doc_author}, 'Correct Doc author');
39ok(!$meta->{doc_editor}, 'Correct Doc editor');
Akrond3a0bad2016-02-26 14:07:58 +010040
Akron35db6e32016-03-17 22:42:22 +010041ok(!$meta->{corpus_title}, 'Correct Corpus title');
42ok(!$meta->{corpus_sub_title}, 'Correct Corpus Sub title');
Akrond3a0bad2016-02-26 14:07:58 +010043
44# Tokenization
45use_ok('KorAP::XML::Tokenizer');
46
47my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/);
48
49# Get tokenization
50my $tokens = KorAP::XML::Tokenizer->new(
51 path => $doc->path,
52 doc => $doc,
53 foundry => $token_base_foundry,
54 layer => $token_base_layer,
55 name => 'tokens'
56);
57ok($tokens, 'Token Object is fine');
58ok($tokens->parse, 'Token parsing is fine');
59
60my $output = $tokens->to_data;
61
62is(substr($output->{data}->{text}, 0, 100), 'A bzw. a ist der erste Buchstabe des lateinischen Alphabets und ein Vokal. Der Buchstabe A hat in de', 'Primary Data');
63is($output->{data}->{name}, 'tokens', 'tokenName');
64is($output->{data}->{tokenSource}, 'opennlp#tokens', 'tokenSource');
65
66is($output->{version}, '0.03', 'version');
67is($output->{data}->{foundries}, '', 'Foundries');
68is($output->{data}->{layerInfos}, '', 'layerInfos');
69is($output->{data}->{stream}->[0]->[4], 's:A', 'data');
70
71$tokens->add('Mate', 'Dependency');
72
73my $stream = $tokens->to_data->{data}->{stream};
74
Akron75ba57d2016-03-07 23:36:27 +010075# This is not a goot relation example
76is($stream->[77]->[0],
77 '<:mate/d:--$<b>34<i>498<i>499<i>78<i>78',
78 'element to term');
Akron88000f92016-03-05 12:39:57 +010079#is($stream->[77]->[1], '<>:mate/d:&&&$<b>64<i>498<i>499<i>78<b>0<s>1', 'element to term');
Akron75ba57d2016-03-07 23:36:27 +010080is($stream->[78]->[0], '>:mate/d:--$<b>33<i>498<i>499<i>77<i>78', 'term to element');
Akron88000f92016-03-05 12:39:57 +010081# is($stream->[78]->[3], 'mate/d:&&&$<b>128<s>1', 'Node');
Akrond3a0bad2016-02-26 14:07:58 +010082
83
84done_testing;
85__END__
86
87
88
89