blob: 1cf171179f3cec27e28f7497645238e7658b6b04 [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');
21# my $path = '/home/ndiewald/Repositories/korap/KorAP-sandbox/KorAP-lucene-indexer/t/GOE/AGA/03828';
22
23ok(my $doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
24ok($doc->parse, 'Parse document');
25
26is($doc->text_sigle, 'WPD_AAA.00001', 'Correct text sigle');
27is($doc->doc_sigle, 'WPD_AAA', 'Correct document sigle');
28is($doc->corpus_sigle, 'WPD', 'Correct corpus sigle');
29
Akron35db6e32016-03-17 22:42:22 +010030my $meta = $doc->meta;
31is($meta->{title}, 'A', 'Title');
32is($meta->{pub_place}, 'URL:http://de.wikipedia.org', 'PubPlace');
33is($meta->{pub_date}, '20050328', 'Creation Date');
34ok(!$meta->{sub_title}, 'SubTitle');
35is($meta->{author}, 'Ruru; Jens.Ol; Aglarech; u.a.', 'Author');
Akrond3a0bad2016-02-26 14:07:58 +010036
Akron35db6e32016-03-17 22:42:22 +010037ok(!$meta->{doc_title}, 'Correct Doc title');
38ok(!$meta->{doc_sub_title}, 'Correct Doc Sub title');
39ok(!$meta->{doc_author}, 'Correct Doc author');
40ok(!$meta->{doc_editor}, 'Correct Doc editor');
Akrond3a0bad2016-02-26 14:07:58 +010041
Akron35db6e32016-03-17 22:42:22 +010042ok(!$meta->{corpus_title}, 'Correct Corpus title');
43ok(!$meta->{corpus_sub_title}, 'Correct Corpus Sub title');
Akrond3a0bad2016-02-26 14:07:58 +010044
45# Tokenization
46use_ok('KorAP::XML::Tokenizer');
47
48my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/);
49
50# Get tokenization
51my $tokens = KorAP::XML::Tokenizer->new(
52 path => $doc->path,
53 doc => $doc,
54 foundry => $token_base_foundry,
55 layer => $token_base_layer,
56 name => 'tokens'
57);
58ok($tokens, 'Token Object is fine');
59ok($tokens->parse, 'Token parsing is fine');
60
61my $output = $tokens->to_data;
62
63is(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');
64is($output->{data}->{name}, 'tokens', 'tokenName');
65is($output->{data}->{tokenSource}, 'opennlp#tokens', 'tokenSource');
66
67is($output->{version}, '0.03', 'version');
68is($output->{data}->{foundries}, '', 'Foundries');
69is($output->{data}->{layerInfos}, '', 'layerInfos');
70is($output->{data}->{stream}->[0]->[4], 's:A', 'data');
71
72$tokens->add('Mate', 'Dependency');
73
74my $stream = $tokens->to_data->{data}->{stream};
75
Akron75ba57d2016-03-07 23:36:27 +010076# This is not a goot relation example
77is($stream->[77]->[0],
78 '<:mate/d:--$<b>34<i>498<i>499<i>78<i>78',
79 'element to term');
Akron88000f92016-03-05 12:39:57 +010080#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 +010081is($stream->[78]->[0], '>:mate/d:--$<b>33<i>498<i>499<i>77<i>78', 'term to element');
Akron88000f92016-03-05 12:39:57 +010082# is($stream->[78]->[3], 'mate/d:&&&$<b>128<s>1', 'Node');
Akrond3a0bad2016-02-26 14:07:58 +010083
84
85done_testing;
86__END__
87
88
89
90