blob: bc073edcdbd3a2346a637f449d4e8216e1e83546 [file] [log] [blame]
Akronc3881502017-01-20 14:36:37 +01001use strict;
2use warnings;
3use Test::More;
4use Data::Dumper;
5use JSON::XS;
6
Akronfab17d32020-07-31 14:38:29 +02007if ($ENV{SKIP_REAL}) {
8 plan skip_all => 'Skip real tests';
9};
10
Akronc3881502017-01-20 14:36:37 +010011use Benchmark qw/:hireswallclock/;
12
13my $t = Benchmark->new;
14
15use utf8;
16use lib 'lib', '../lib';
17
18use File::Basename 'dirname';
19use File::Spec::Functions 'catdir';
20
21use_ok('KorAP::XML::Krill');
22
23# This will Check DRuKoLa-Files
24
25# New
26# BBU/BLOG/83709_a_82384
Akron414ec952020-08-03 15:48:43 +020027my $path = catdir(dirname(__FILE__), 'corpus','CoRoLa','BBU','BLOG','83709_a_82384');
Akronc3881502017-01-20 14:36:37 +010028
29ok(my $doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
30ok($doc->parse, 'Parse document');
31
32is($doc->text_sigle, 'BBU/BLOG/83709_a_82384', 'Correct text sigle');
33is($doc->doc_sigle, 'BBU/BLOG', 'Correct document sigle');
34is($doc->corpus_sigle, 'BBU', 'Correct corpus sigle');
35
36my $meta = $doc->meta;
Akron5eb3aa02019-01-25 18:30:47 +010037is($meta->{T_title}, 'Schimbă vorba', 'Title');
38is($meta->{S_pub_place}, 'URL:http://www.bucurenci.ro', 'PubPlace');
39is($meta->{D_pub_date}, '20131005', 'Creation Date');
40ok(!$meta->{T_sub_title}, 'SubTitle');
41is($meta->{T_author}, 'Dragoș Bucurenci', 'Author');
Akronc3881502017-01-20 14:36:37 +010042
Akron5eb3aa02019-01-25 18:30:47 +010043ok(!$meta->{A_publisher}, 'Publisher');
44ok(!$meta->{A_editor}, 'Editor');
45is($meta->{A_translator}, '[TRANSLATOR]', 'Translator');
46#is($meta->{S_text_type}, 'Autobiographie', 'Correct Text Type');
47ok(!$meta->{S_text_type_art}, 'Correct Text Type Art');
48# is($meta->{S_text_type_ref}, '', 'Correct Text Type Ref');
49ok(!$meta->{S_text_column}, 'Correct Text Column');
50ok(!$meta->{S_text_domain}, 'Correct Text Domain');
51ok(!$meta->{D_creation_date}, 'Creation Date');
Akronc3881502017-01-20 14:36:37 +010052
53ok(!$meta->{pages}, 'Pages');
Akron5eb3aa02019-01-25 18:30:47 +010054ok(!$meta->{A_file_edition_statement}, 'File Ed Statement');
55ok(!$meta->{A_bibl_edition_statement}, 'Bibl Ed Statement');
56ok(!$meta->{A_reference}, 'Reference');
57is($meta->{S_language}, 'ro', 'Language');
Akronc3881502017-01-20 14:36:37 +010058
Akron5eb3aa02019-01-25 18:30:47 +010059#is($meta->{T_corpus_title}, 'Goethes Werke', 'Correct Corpus title');
60ok(!$meta->{T_corpus_sub_title}, 'Correct Corpus Sub title');
61#is($meta->{T_corpus_author}, 'Goethe, Johann Wolfgang von', 'Correct Corpus author');
62#is($meta->{A_corpus_editor}, 'Trunz, Erich', 'Correct Corpus editor');
Akronc3881502017-01-20 14:36:37 +010063
Akron5eb3aa02019-01-25 18:30:47 +010064#is($meta->{T_doc_title}, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)',
Akronc3881502017-01-20 14:36:37 +010065# 'Correct Doc title');
Akron5eb3aa02019-01-25 18:30:47 +010066ok(!$meta->{T_doc_sub_title}, 'Correct Doc Sub title');
67ok(!$meta->{T_doc_author}, 'Correct Doc author');
68ok(!$meta->{A_doc_editor}, 'Correct Doc editor');
Akronc3881502017-01-20 14:36:37 +010069
70# Tokenization
71use_ok('KorAP::XML::Tokenizer');
72
73my ($token_base_foundry, $token_base_layer) = (qw/Base Tokens_conservative/);
74
75# Get tokenization
76my $tokens = KorAP::XML::Tokenizer->new(
77 path => $doc->path,
78 doc => $doc,
79 foundry => $token_base_foundry,
80 layer => $token_base_layer,
81 name => 'tokens'
82);
83ok($tokens, 'Token Object is fine');
84ok($tokens->parse, 'Token parsing is fine');
85
86my $output = decode_json( $tokens->to_json );
87
88## Base
89$tokens->add('DeReKo', 'Structure', 'base_sentences_paragraphs');
90ok($tokens->add('DRuKoLa', 'Morpho'), 'Add Drukola');
91
92$output = $tokens->to_data;
93
94is($output->{data}->{foundries}, 'dereko dereko/structure dereko/structure/base_sentences_paragraphs drukola drukola/morpho', 'Foundries');
95
96is($output->{data}->{layerInfos}, 'dereko/s=spans drukola/l=tokens drukola/m=tokens drukola/p=tokens', 'layerInfos');
97
98my $token = join('||', @{$output->{data}->{stream}->[7]});
99
100like($token, qr!drukola/l:la!, 'data');
101like($token, qr!drukola/m:msd:Sp!, 'data');
102like($token, qr!drukola/p:ADPOSITION!, 'data');
103
104$token = join('||', @{$output->{data}->{stream}->[9]});
105
106like($token, qr!i:vorba!, 'data');
107like($token, qr!drukola/l:vorbă!, 'data');
108like($token, qr!drukola/m:case:Ncfsry!, 'data');
109like($token, qr!drukola/m:definiteness:yes!, 'data');
110like($token, qr!drukola/m:gender:feminine!, 'data');
111like($token, qr!drukola/p:NOUN!, 'data');
112
Akrona7d0e9f2017-02-03 14:36:21 +0100113
114# New
115# BBU2/BLOG/83709_a_82384
Akron414ec952020-08-03 15:48:43 +0200116$path = catdir(dirname(__FILE__), 'corpus','CoRoLa','BBU2','Blog','83701_a_82376');
Akrona7d0e9f2017-02-03 14:36:21 +0100117
118ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
119ok($doc->parse, 'Parse document');
120
121$meta = $doc->meta;
122
Akron5eb3aa02019-01-25 18:30:47 +0100123ok(!exists $meta->{T_doc_title}, 'No doc title');
Akrona7d0e9f2017-02-03 14:36:21 +0100124ok(!exists $meta->{translator}, 'No translator');
125
Akron5eb3aa02019-01-25 18:30:47 +0100126ok(!exists $meta->{K_text_class}, 'No translator');
Akrona7d0e9f2017-02-03 14:36:21 +0100127
128
Akron38873012017-02-06 20:27:37 +0100129
Akron414ec952020-08-03 15:48:43 +0200130$path = catdir(dirname(__FILE__), 'corpus','CoRoLa','Corola-Journal','-','247_a_537');
Akron38873012017-02-06 20:27:37 +0100131ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
132ok($doc->parse, 'Parse document');
133
134$meta = $doc->meta;
135is($meta->text_sigle, 'Corola-Journal/-/247_a_537', 'Text Sigle');
136is($meta->doc_sigle, 'Corola-Journal/-', 'Doc Sigle');
137is($meta->corpus_sigle, 'Corola-Journal', 'Corpus Sigle');
Akron5eb3aa02019-01-25 18:30:47 +0100138is($meta->{K_text_class}->[0], 'Sport', 'Text class');
Akron38873012017-02-06 20:27:37 +0100139
140
Akron414ec952020-08-03 15:48:43 +0200141$path = catdir(dirname(__FILE__), 'corpus','CoRoLa','Corola-Journal','COLEGIUL NATIONAL „OCTAV BANCILA“ - IASI','326_a_562');
Akron38873012017-02-06 20:27:37 +0100142ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
143ok($doc->parse, 'Parse document');
144
145$meta = $doc->meta;
146is($meta->text_sigle, 'Corola-Journal/COLEGIUL NATIONAL „OCTAV BANCILA“ - IASI/326_a_562', 'Text Sigle');
147is($meta->doc_sigle, 'Corola-Journal/COLEGIUL NATIONAL „OCTAV BANCILA“ - IASI', 'Doc Sigle');
148is($meta->corpus_sigle, 'Corola-Journal', 'Corpus Sigle');
Akron5eb3aa02019-01-25 18:30:47 +0100149is($meta->{T_title}, 'APOGEUL ARHITECTURĂ ȘI DESIGN', 'Title');
Akron38873012017-02-06 20:27:37 +0100150
Akronc3881502017-01-20 14:36:37 +0100151done_testing;
152__END__