blob: a1c15c0314cd24498b5bd5a3afd9d64aaf87acfa [file] [log] [blame]
Akronb2636cf2016-01-26 18:42:44 +01001use strict;
2use warnings;
3use Test::More;
4use File::Basename 'dirname';
5use File::Spec::Functions 'catdir';
6use Data::Dumper;
Akrone4c2e412016-01-28 15:10:50 +01007use KorAP::XML::Tokenizer;
8use KorAP::XML::Krill;
Akronb2636cf2016-01-26 18:42:44 +01009use utf8;
10
11my $path = catdir(dirname(__FILE__), 'TEST', 'BSP', 1);
12
Akrone4c2e412016-01-28 15:10:50 +010013ok(my $doc = KorAP::XML::Krill->new(
Akron35db6e32016-03-17 22:42:22 +010014 path => $path . '/',
15 meta_type => 'Sgbr'
Akronb2636cf2016-01-26 18:42:44 +010016), 'Create Document');
17
18ok($doc->parse, 'Parse document');
19
20like($doc->path, qr!$path/!, 'Path');
21
22# Metdata
23is($doc->text_sigle, 'TEST_BSP.1', 'ID-text');
24is($doc->doc_sigle, 'TEST_BSP', 'ID-doc');
25is($doc->corpus_sigle, 'TEST', 'ID-corpus');
26
Akron35db6e32016-03-17 22:42:22 +010027my $meta = $doc->meta;
Akron15e6fa72016-02-04 15:02:20 +010028
Akron35db6e32016-03-17 22:42:22 +010029is($meta->{title}, 'Sommerüberraschung', 'title');
30is($meta->{author}, 'TEST.BSP.Autoren.1', 'Author');
31is($meta->{'sgbr_author_age_class'}, 'X', 'AgeClass');
Akrona8665782016-01-27 21:47:57 +010032
Akron35db6e32016-03-17 22:42:22 +010033is($meta->{'sgbr_author_sex'}, 'M', 'Sex');
34is($meta->{'sgbr_kodex'}, 'M', 'Kodex');
Akrona8665782016-01-27 21:47:57 +010035
Akron35db6e32016-03-17 22:42:22 +010036is($meta->{doc_title}, 'Beispielkorpus', 'Doc: title');
37is($meta->{doc_sub_title}, 'Subkorpus Beispieltext', 'Doc: subtitle');
Akrona8665782016-01-27 21:47:57 +010038
Akron35db6e32016-03-17 22:42:22 +010039is($meta->{language}, 'de', 'Language');
Akrona8665782016-01-27 21:47:57 +010040
Akron35db6e32016-03-17 22:42:22 +010041ok(!$meta->{publisher}, 'Publisher');
42ok(!$meta->{editor}, 'Editor');
43ok(!$meta->{text_type}, 'Text Type');
44ok(!$meta->{text_type_art}, 'Text Type Art');
45ok(!$meta->{text_type_ref}, 'Text Type Ref');
46ok(!$meta->{text_column}, 'Text Column');
47ok(!$meta->{text_domain}, 'Text Domain');
48ok(!$meta->{creation_date}, 'Creation Date');
49ok(!$meta->{license}, 'License');
50ok(!$meta->{pages}, 'Pages');
51ok(!$meta->{file_edition_statement}, 'File Edition Statement');
52ok(!$meta->{bibl_edition_statement}, 'Bibl Edition Statement');
53ok(!$meta->{reference}, 'Reference');
Akrona8665782016-01-27 21:47:57 +010054
Akron35db6e32016-03-17 22:42:22 +010055ok(!$meta->{doc_editor}, 'Doc: editor');
56ok(!$meta->{doc_author}, 'Doc: author');
57
58ok(!$meta->{corpus_title}, 'Corpus: title');
59ok(!$meta->{corpus_sub_title}, 'Corpus: subtitle');
60ok(!$meta->{corpus_editor}, 'Corpus: editor');
61ok(!$meta->{corpus_author}, 'Corpus: author');
Akronb2636cf2016-01-26 18:42:44 +010062
Akron12ef05b2016-01-31 23:58:53 +010063my $hash = $doc->to_hash;
64is($hash->{title}, 'Sommerüberraschung', 'Corpus title');
Akron35db6e32016-03-17 22:42:22 +010065is($hash->{sgbrAuthorSex}, 'M', 'additional');
Akron12ef05b2016-01-31 23:58:53 +010066
Akron15e6fa72016-02-04 15:02:20 +010067# Sgbr specific keywords
Akron35db6e32016-03-17 22:42:22 +010068is($meta->keywords('keywords'), 'sgbrAuthorAgeClass:X sgbrAuthorSex:M sgbrKodex:M');
Akron15e6fa72016-02-04 15:02:20 +010069
Akronfd0707e2016-02-11 22:13:36 +010070
Akronb2636cf2016-01-26 18:42:44 +010071done_testing;
Akrona8665782016-01-27 21:47:57 +010072
73
74__END__