blob: 1eb458701e431d58e4f1f4871b9d423b98c1a65b [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');
Akron578af4b2017-01-20 16:28:50 +010041is($meta->{translator}, '[TRANSLATOR]', 'Translator');
Akronc3881502017-01-20 14:36:37 +010042#is($meta->{text_type}, 'Autobiographie', 'Correct Text Type');
43ok(!$meta->{text_type_art}, 'Correct Text Type Art');
44# is($meta->{text_type_ref}, '', 'Correct Text Type Ref');
45ok(!$meta->{text_column}, 'Correct Text Column');
46ok(!$meta->{text_domain}, 'Correct Text Domain');
47ok(!$meta->{creation_date}, 'Creation Date');
48
49ok(!$meta->{pages}, 'Pages');
50ok(!$meta->{file_edition_statement}, 'File Ed Statement');
51ok(!$meta->{bibl_edition_statement}, 'Bibl Ed Statement');
52ok(!$meta->{reference}, 'Reference');
53is($meta->{language}, 'ro', 'Language');
54
55#is($meta->{corpus_title}, 'Goethes Werke', 'Correct Corpus title');
56ok(!$meta->{corpus_sub_title}, 'Correct Corpus Sub title');
57#is($meta->{corpus_author}, 'Goethe, Johann Wolfgang von', 'Correct Corpus author');
58#is($meta->{corpus_editor}, 'Trunz, Erich', 'Correct Corpus editor');
59
60#is($meta->{doc_title}, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)',
61# 'Correct Doc title');
62ok(!$meta->{doc_sub_title}, 'Correct Doc Sub title');
63ok(!$meta->{doc_author}, 'Correct Doc author');
64ok(!$meta->{doc_editor}, 'Correct Doc editor');
65
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
112$path = catdir(dirname(__FILE__), '../corpus/BBU2/Blog/83701_a_82376');
113
114
115
116ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
117ok($doc->parse, 'Parse document');
118
119$meta = $doc->meta;
120
121ok(!exists $meta->{doc_title}, 'No doc title');
122ok(!exists $meta->{translator}, 'No translator');
123
124ok(!exists $meta->{text_class}, 'No translator');
125
126
Akronc3881502017-01-20 14:36:37 +0100127done_testing;
128__END__