blob: 244101ad35df21e55000bb61d74cd1b0eacc13f7 [file] [log] [blame]
Akronc3881502017-01-20 14:36:37 +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# This will Check DRuKoLa-Files
20
21# New
22# BBU/BLOG/83709_a_82384
23my $path = catdir(dirname(__FILE__), '../corpus/BBU/BLOG/83709_a_82384');
24
25ok(my $doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
26ok($doc->parse, 'Parse document');
27
28is($doc->text_sigle, 'BBU/BLOG/83709_a_82384', 'Correct text sigle');
29is($doc->doc_sigle, 'BBU/BLOG', 'Correct document sigle');
30is($doc->corpus_sigle, 'BBU', 'Correct corpus sigle');
31
32my $meta = $doc->meta;
33is($meta->{title}, 'Schimbă vorba', 'Title');
34is($meta->{pub_place}, 'URL:http://www.bucurenci.ro', 'PubPlace');
35is($meta->{pub_date}, '20131005', 'Creation Date');
36ok(!$meta->{sub_title}, 'SubTitle');
37is($meta->{author}, 'Dragoș Bucurenci', 'Author');
38
39ok(!$meta->{publisher}, 'Publisher');
40ok(!$meta->{editor}, 'Editor');
41#is($meta->{text_type}, 'Autobiographie', 'Correct Text Type');
42ok(!$meta->{text_type_art}, 'Correct Text Type Art');
43# is($meta->{text_type_ref}, '', 'Correct Text Type Ref');
44ok(!$meta->{text_column}, 'Correct Text Column');
45ok(!$meta->{text_domain}, 'Correct Text Domain');
46ok(!$meta->{creation_date}, 'Creation Date');
47
48ok(!$meta->{pages}, 'Pages');
49ok(!$meta->{file_edition_statement}, 'File Ed Statement');
50ok(!$meta->{bibl_edition_statement}, 'Bibl Ed Statement');
51ok(!$meta->{reference}, 'Reference');
52is($meta->{language}, 'ro', 'Language');
53
54#is($meta->{corpus_title}, 'Goethes Werke', 'Correct Corpus title');
55ok(!$meta->{corpus_sub_title}, 'Correct Corpus Sub title');
56#is($meta->{corpus_author}, 'Goethe, Johann Wolfgang von', 'Correct Corpus author');
57#is($meta->{corpus_editor}, 'Trunz, Erich', 'Correct Corpus editor');
58
59#is($meta->{doc_title}, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)',
60# 'Correct Doc title');
61ok(!$meta->{doc_sub_title}, 'Correct Doc Sub title');
62ok(!$meta->{doc_author}, 'Correct Doc author');
63ok(!$meta->{doc_editor}, 'Correct Doc editor');
64
65# Tokenization
66use_ok('KorAP::XML::Tokenizer');
67
68my ($token_base_foundry, $token_base_layer) = (qw/Base Tokens_conservative/);
69
70# Get tokenization
71my $tokens = KorAP::XML::Tokenizer->new(
72 path => $doc->path,
73 doc => $doc,
74 foundry => $token_base_foundry,
75 layer => $token_base_layer,
76 name => 'tokens'
77);
78ok($tokens, 'Token Object is fine');
79ok($tokens->parse, 'Token parsing is fine');
80
81my $output = decode_json( $tokens->to_json );
82
83## Base
84$tokens->add('DeReKo', 'Structure', 'base_sentences_paragraphs');
85ok($tokens->add('DRuKoLa', 'Morpho'), 'Add Drukola');
86
87$output = $tokens->to_data;
88
89is($output->{data}->{foundries}, 'dereko dereko/structure dereko/structure/base_sentences_paragraphs drukola drukola/morpho', 'Foundries');
90
91is($output->{data}->{layerInfos}, 'dereko/s=spans drukola/l=tokens drukola/m=tokens drukola/p=tokens', 'layerInfos');
92
93my $token = join('||', @{$output->{data}->{stream}->[7]});
94
95like($token, qr!drukola/l:la!, 'data');
96like($token, qr!drukola/m:msd:Sp!, 'data');
97like($token, qr!drukola/p:ADPOSITION!, 'data');
98
99$token = join('||', @{$output->{data}->{stream}->[9]});
100
101like($token, qr!i:vorba!, 'data');
102like($token, qr!drukola/l:vorbă!, 'data');
103like($token, qr!drukola/m:case:Ncfsry!, 'data');
104like($token, qr!drukola/m:definiteness:yes!, 'data');
105like($token, qr!drukola/m:gender:feminine!, 'data');
106like($token, qr!drukola/p:NOUN!, 'data');
107
108done_testing;
109__END__