blob: 9a9244412b98a80290a0bc16d10190cb9bf84470 [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
Akron38873012017-02-06 20:27:37 +010023my $path = catdir(dirname(__FILE__), '../corpus/CoRoLa/BBU/BLOG/83709_a_82384');
Akronc3881502017-01-20 14:36:37 +010024
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;
Akron5eb3aa02019-01-25 18:30:47 +010033is($meta->{T_title}, 'Schimbă vorba', 'Title');
34is($meta->{S_pub_place}, 'URL:http://www.bucurenci.ro', 'PubPlace');
35is($meta->{D_pub_date}, '20131005', 'Creation Date');
36ok(!$meta->{T_sub_title}, 'SubTitle');
37is($meta->{T_author}, 'Dragoș Bucurenci', 'Author');
Akronc3881502017-01-20 14:36:37 +010038
Akron5eb3aa02019-01-25 18:30:47 +010039ok(!$meta->{A_publisher}, 'Publisher');
40ok(!$meta->{A_editor}, 'Editor');
41is($meta->{A_translator}, '[TRANSLATOR]', 'Translator');
42#is($meta->{S_text_type}, 'Autobiographie', 'Correct Text Type');
43ok(!$meta->{S_text_type_art}, 'Correct Text Type Art');
44# is($meta->{S_text_type_ref}, '', 'Correct Text Type Ref');
45ok(!$meta->{S_text_column}, 'Correct Text Column');
46ok(!$meta->{S_text_domain}, 'Correct Text Domain');
47ok(!$meta->{D_creation_date}, 'Creation Date');
Akronc3881502017-01-20 14:36:37 +010048
49ok(!$meta->{pages}, 'Pages');
Akron5eb3aa02019-01-25 18:30:47 +010050ok(!$meta->{A_file_edition_statement}, 'File Ed Statement');
51ok(!$meta->{A_bibl_edition_statement}, 'Bibl Ed Statement');
52ok(!$meta->{A_reference}, 'Reference');
53is($meta->{S_language}, 'ro', 'Language');
Akronc3881502017-01-20 14:36:37 +010054
Akron5eb3aa02019-01-25 18:30:47 +010055#is($meta->{T_corpus_title}, 'Goethes Werke', 'Correct Corpus title');
56ok(!$meta->{T_corpus_sub_title}, 'Correct Corpus Sub title');
57#is($meta->{T_corpus_author}, 'Goethe, Johann Wolfgang von', 'Correct Corpus author');
58#is($meta->{A_corpus_editor}, 'Trunz, Erich', 'Correct Corpus editor');
Akronc3881502017-01-20 14:36:37 +010059
Akron5eb3aa02019-01-25 18:30:47 +010060#is($meta->{T_doc_title}, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)',
Akronc3881502017-01-20 14:36:37 +010061# 'Correct Doc title');
Akron5eb3aa02019-01-25 18:30:47 +010062ok(!$meta->{T_doc_sub_title}, 'Correct Doc Sub title');
63ok(!$meta->{T_doc_author}, 'Correct Doc author');
64ok(!$meta->{A_doc_editor}, 'Correct Doc editor');
Akronc3881502017-01-20 14:36:37 +010065
66# Tokenization
67use_ok('KorAP::XML::Tokenizer');
68
69my ($token_base_foundry, $token_base_layer) = (qw/Base Tokens_conservative/);
70
71# Get tokenization
72my $tokens = KorAP::XML::Tokenizer->new(
73 path => $doc->path,
74 doc => $doc,
75 foundry => $token_base_foundry,
76 layer => $token_base_layer,
77 name => 'tokens'
78);
79ok($tokens, 'Token Object is fine');
80ok($tokens->parse, 'Token parsing is fine');
81
82my $output = decode_json( $tokens->to_json );
83
84## Base
85$tokens->add('DeReKo', 'Structure', 'base_sentences_paragraphs');
86ok($tokens->add('DRuKoLa', 'Morpho'), 'Add Drukola');
87
88$output = $tokens->to_data;
89
90is($output->{data}->{foundries}, 'dereko dereko/structure dereko/structure/base_sentences_paragraphs drukola drukola/morpho', 'Foundries');
91
92is($output->{data}->{layerInfos}, 'dereko/s=spans drukola/l=tokens drukola/m=tokens drukola/p=tokens', 'layerInfos');
93
94my $token = join('||', @{$output->{data}->{stream}->[7]});
95
96like($token, qr!drukola/l:la!, 'data');
97like($token, qr!drukola/m:msd:Sp!, 'data');
98like($token, qr!drukola/p:ADPOSITION!, 'data');
99
100$token = join('||', @{$output->{data}->{stream}->[9]});
101
102like($token, qr!i:vorba!, 'data');
103like($token, qr!drukola/l:vorbă!, 'data');
104like($token, qr!drukola/m:case:Ncfsry!, 'data');
105like($token, qr!drukola/m:definiteness:yes!, 'data');
106like($token, qr!drukola/m:gender:feminine!, 'data');
107like($token, qr!drukola/p:NOUN!, 'data');
108
Akrona7d0e9f2017-02-03 14:36:21 +0100109
110# New
111# BBU2/BLOG/83709_a_82384
Akron38873012017-02-06 20:27:37 +0100112$path = catdir(dirname(__FILE__), '../corpus/CoRoLa/BBU2/Blog/83701_a_82376');
Akrona7d0e9f2017-02-03 14:36:21 +0100113
114ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
115ok($doc->parse, 'Parse document');
116
117$meta = $doc->meta;
118
Akron5eb3aa02019-01-25 18:30:47 +0100119ok(!exists $meta->{T_doc_title}, 'No doc title');
Akrona7d0e9f2017-02-03 14:36:21 +0100120ok(!exists $meta->{translator}, 'No translator');
121
Akron5eb3aa02019-01-25 18:30:47 +0100122ok(!exists $meta->{K_text_class}, 'No translator');
Akrona7d0e9f2017-02-03 14:36:21 +0100123
124
Akron38873012017-02-06 20:27:37 +0100125
126$path = catdir(dirname(__FILE__), '../corpus/CoRoLa/Corola-Journal/-/247_a_537');
127ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
128ok($doc->parse, 'Parse document');
129
130$meta = $doc->meta;
131is($meta->text_sigle, 'Corola-Journal/-/247_a_537', 'Text Sigle');
132is($meta->doc_sigle, 'Corola-Journal/-', 'Doc Sigle');
133is($meta->corpus_sigle, 'Corola-Journal', 'Corpus Sigle');
Akron5eb3aa02019-01-25 18:30:47 +0100134is($meta->{K_text_class}->[0], 'Sport', 'Text class');
Akron38873012017-02-06 20:27:37 +0100135
136
137$path = catdir(dirname(__FILE__), '../corpus/CoRoLa/Corola-Journal/COLEGIUL NATIONAL „OCTAV BANCILA“ - IASI/326_a_562');
138ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
139ok($doc->parse, 'Parse document');
140
141$meta = $doc->meta;
142is($meta->text_sigle, 'Corola-Journal/COLEGIUL NATIONAL „OCTAV BANCILA“ - IASI/326_a_562', 'Text Sigle');
143is($meta->doc_sigle, 'Corola-Journal/COLEGIUL NATIONAL „OCTAV BANCILA“ - IASI', 'Doc Sigle');
144is($meta->corpus_sigle, 'Corola-Journal', 'Corpus Sigle');
Akron5eb3aa02019-01-25 18:30:47 +0100145is($meta->{T_title}, 'APOGEUL ARHITECTURĂ ȘI DESIGN', 'Title');
Akron38873012017-02-06 20:27:37 +0100146
Akronc3881502017-01-20 14:36:37 +0100147done_testing;
148__END__