blob: dcaf6cf4e77c48e458ec870ef22960220c46a1fc [file] [log] [blame]
Akron414ec952020-08-03 15:48:43 +02001use strict;
2use warnings;
3use Test::More;
4use File::Basename 'dirname';
5use File::Spec::Functions 'catdir';
6use Data::Dumper;
7use KorAP::XML::Tokenizer;
8use KorAP::XML::Krill;
9use utf8;
10
11if ($ENV{SKIP_REAL}) {
12 plan skip_all => 'Skip real tests';
13};
14
15my $path = catdir(dirname(__FILE__), 'TEST', 'BSP', 1);
16
17ok(my $doc = KorAP::XML::Krill->new(
18 path => $path . '/',
19 meta_type => 'Sgbr'
20), 'Create Document');
21
22ok($doc->parse, 'Parse document');
23
24like($doc->path, qr!\Q$path\E/!, 'Path');
25
26# Metdata
27is($doc->text_sigle, 'TEST/BSP/1', 'ID-text');
28is($doc->doc_sigle, 'TEST/BSP', 'ID-doc');
29is($doc->corpus_sigle, 'TEST', 'ID-corpus');
30
31my $meta = $doc->meta;
32
33is($meta->{T_title}, 'Sommerüberraschung', 'title');
34is($meta->{T_author}, 'TEST.BSP.Autoren.1', 'Author');
35is($meta->{'S_sgbr_author_age_class'}, 'X', 'AgeClass');
36
37is($meta->{'S_sgbr_author_sex'}, 'M', 'Sex');
38is($meta->{'S_sgbr_kodex'}, 'M', 'Kodex');
39
40is($meta->{T_doc_title}, 'Beispielkorpus', 'Doc: title');
41is($meta->{T_doc_sub_title}, 'Subkorpus Beispieltext', 'Doc: subtitle');
42
43is($meta->{S_language}, 'de', 'Language');
44
45ok(!$meta->{A_publisher}, 'Publisher');
46ok(!$meta->{A_editor}, 'Editor');
47ok(!$meta->{S_text_type}, 'Text Type');
48ok(!$meta->{S_text_type_art}, 'Text Type Art');
49ok(!$meta->{S_text_type_ref}, 'Text Type Ref');
50ok(!$meta->{S_text_column}, 'Text Column');
51ok(!$meta->{S_text_domain}, 'Text Domain');
52ok(!$meta->{D_creation_date}, 'Creation Date');
53ok(!$meta->{license}, 'License');
54ok(!$meta->{pages}, 'Pages');
55ok(!$meta->{A_file_edition_statement}, 'File Edition Statement');
56ok(!$meta->{A_bibl_edition_statement}, 'Bibl Edition Statement');
57ok(!$meta->{A_reference}, 'Reference');
58
59ok(!$meta->{A_doc_editor}, 'Doc: editor');
60ok(!$meta->{T_doc_author}, 'Doc: author');
61
62ok(!$meta->{T_corpus_title}, 'Corpus: title');
63ok(!$meta->{T_corpus_sub_title}, 'Corpus: subtitle');
64ok(!$meta->{A_corpus_editor}, 'Corpus: editor');
65ok(!$meta->{T_corpus_author}, 'Corpus: author');
66
67my $hash = $doc->to_hash;
68is($hash->{title}, 'Sommerüberraschung', 'Corpus title');
69is($hash->{sgbrAuthorSex}, 'M', 'additional');
70
71# Sgbr specific keywords
72is($meta->keywords('K_keywords'), 'sgbrAuthorAgeClass:X sgbrAuthorSex:M sgbrKodex:M');
73
74
75done_testing;
76
77
78__END__