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