blob: c0f5dc7ff5f837e69bdcb627fa731068fe8e1220 [file] [log] [blame]
Akron2e840a72022-02-03 09:49:26 +01001use strict;
2use warnings;
3use Test::More;
4use Data::Dumper;
5use JSON::XS;
6
7if ($ENV{SKIP_REAL}) {
8 plan skip_all => 'Skip real tests';
9};
10
11use utf8;
12use lib 'lib', '../lib';
13
14use File::Basename 'dirname';
15use File::Spec::Functions 'catdir';
16
17use_ok('KorAP::XML::Krill');
18
19my $path = catdir(dirname(__FILE__), 'corpus','NDY','296','008718');
20
21ok(my $doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document');
22ok($doc->parse, 'Parse document');
23
24is($doc->text_sigle, 'NDY/296/008718', 'Correct text sigle');
25is($doc->doc_sigle, 'NDY/296', 'Correct document sigle');
26is($doc->corpus_sigle, 'NDY', 'Correct corpus sigle');
27
28my $meta = $doc->meta;
29
30like($meta->{T_title}, qr!^Kommentar zu: LOCKE hat mein MERCEDES AMG ZERSTÖRT!, 'Title');
31ok(!$meta->{T_sub_title}, 'SubTitle');
32is($meta->{T_author}, 'Livia Banse', 'Author');
33ok(!$meta->{A_editor}, 'Editor');
34is($meta->{S_pub_place}, 'San Bruno, California');
35is($meta->{A_publisher}, 'YouTube', 'Publisher');
36
37is($meta->{S_text_type},'Kurzmeldungen: YouTube-Kommentare', 'No Text Type');
38ok(!$meta->{S_text_type_art}, 'No Text Type Art');
39ok(!$meta->{S_text_type_ref}, 'No Text Type Ref');
40ok(!$meta->{S_text_domain}, 'No Text Domain');
41ok(!$meta->{S_text_column}, 'No Text Column');
42
43is($meta->{K_text_class}->[0], 'entertainment', 'Correct Text Class');
44ok(!$meta->{K_text_class}->[1], 'Correct Text Class');
45
46is($meta->{D_pub_date}, '20171204', 'Creation date');
47is($meta->{D_creation_date}, '20171204', 'Creation date');
48is($meta->{S_availability}, 'QAO-NC-LOC:ids', 'License');
49ok(!$meta->{A_pages}, 'Pages');
50
51ok(!$meta->{A_file_edition_statement}, 'File Statement');
52ok(!$meta->{A_bibl_edition_statement}, 'Bibl Statement');
53
54like($meta->{A_reference}, qr!NDY\/296\.008718, YouTube, 04\.12\.2017\. Livia Banse: Kommentar zu: LOCKE hat mein MERCEDES AMG ZERSTÖRT.* \(AutoUnfall\), - YouTube!, 'Reference');
55
56is($meta->{S_language}, 'de', 'Language');
57
58is($meta->{T_corpus_title}, 'YouTube', 'Correct Corpus title');
59ok(!$meta->{T_corpus_sub_title}, 'Correct Corpus sub title');
60ok(!$meta->{T_corpus_author}, 'Correct Corpus author');
61ok(!$meta->{A_corpus_editor}, 'Correct Corpus editor');
62
63like($meta->{T_doc_title}, qr!LOCKE hat mein MERCEDES AMG ZERSTÖRT\!.* \(AutoUnfall\)!, 'Correct Doc title');
64ok(!$meta->{T_doc_sub_title}, 'Correct Doc sub title');
65is($meta->{T_doc_author},'Leon Machère', 'Correct Doc author');
66ok(!$meta->{A_doc_editor}, 'Correct doc editor');
67
68
Akron2daf8fe2023-02-27 12:55:04 +010069# Tokenization
70use_ok('KorAP::XML::Tokenizer');
71
72my ($token_base_foundry, $token_base_layer) = (qw/Base Tokens/);
73
74# Get tokenization
75my $tokens = KorAP::XML::Tokenizer->new(
76 path => $doc->path,
77 doc => $doc,
78 foundry => $token_base_foundry,
79 layer => $token_base_layer,
80 name => 'tokens'
81);
82
83ok($tokens, 'Token Object is fine');
84ok($tokens->parse, 'Token parsing is fine');
85
Akron2e840a72022-02-03 09:49:26 +010086done_testing;
87__END__