Akron | b2636cf | 2016-01-26 18:42:44 +0100 | [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; |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 7 | use KorAP::XML::Tokenizer; |
| 8 | use KorAP::XML::Krill; |
Akron | b2636cf | 2016-01-26 18:42:44 +0100 | [diff] [blame] | 9 | use utf8; |
| 10 | |
| 11 | my $path = catdir(dirname(__FILE__), 'TEST', 'BSP', 1); |
| 12 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 13 | ok(my $doc = KorAP::XML::Krill->new( |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 14 | path => $path . '/', |
| 15 | meta_type => 'Sgbr' |
Akron | b2636cf | 2016-01-26 18:42:44 +0100 | [diff] [blame] | 16 | ), 'Create Document'); |
| 17 | |
| 18 | ok($doc->parse, 'Parse document'); |
| 19 | |
| 20 | like($doc->path, qr!$path/!, 'Path'); |
| 21 | |
| 22 | # Metdata |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 23 | is($doc->text_sigle, 'TEST/BSP/1', 'ID-text'); |
| 24 | is($doc->doc_sigle, 'TEST/BSP', 'ID-doc'); |
Akron | b2636cf | 2016-01-26 18:42:44 +0100 | [diff] [blame] | 25 | is($doc->corpus_sigle, 'TEST', 'ID-corpus'); |
| 26 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 27 | my $meta = $doc->meta; |
Akron | 15e6fa7 | 2016-02-04 15:02:20 +0100 | [diff] [blame] | 28 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 29 | is($meta->{title}, 'Sommerüberraschung', 'title'); |
| 30 | is($meta->{author}, 'TEST.BSP.Autoren.1', 'Author'); |
| 31 | is($meta->{'sgbr_author_age_class'}, 'X', 'AgeClass'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 32 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 33 | is($meta->{'sgbr_author_sex'}, 'M', 'Sex'); |
| 34 | is($meta->{'sgbr_kodex'}, 'M', 'Kodex'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 35 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 36 | is($meta->{doc_title}, 'Beispielkorpus', 'Doc: title'); |
| 37 | is($meta->{doc_sub_title}, 'Subkorpus Beispieltext', 'Doc: subtitle'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 38 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 39 | is($meta->{language}, 'de', 'Language'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 40 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 41 | ok(!$meta->{publisher}, 'Publisher'); |
| 42 | ok(!$meta->{editor}, 'Editor'); |
| 43 | ok(!$meta->{text_type}, 'Text Type'); |
| 44 | ok(!$meta->{text_type_art}, 'Text Type Art'); |
| 45 | ok(!$meta->{text_type_ref}, 'Text Type Ref'); |
| 46 | ok(!$meta->{text_column}, 'Text Column'); |
| 47 | ok(!$meta->{text_domain}, 'Text Domain'); |
| 48 | ok(!$meta->{creation_date}, 'Creation Date'); |
| 49 | ok(!$meta->{license}, 'License'); |
| 50 | ok(!$meta->{pages}, 'Pages'); |
| 51 | ok(!$meta->{file_edition_statement}, 'File Edition Statement'); |
| 52 | ok(!$meta->{bibl_edition_statement}, 'Bibl Edition Statement'); |
| 53 | ok(!$meta->{reference}, 'Reference'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 54 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 55 | ok(!$meta->{doc_editor}, 'Doc: editor'); |
| 56 | ok(!$meta->{doc_author}, 'Doc: author'); |
| 57 | |
| 58 | ok(!$meta->{corpus_title}, 'Corpus: title'); |
| 59 | ok(!$meta->{corpus_sub_title}, 'Corpus: subtitle'); |
| 60 | ok(!$meta->{corpus_editor}, 'Corpus: editor'); |
| 61 | ok(!$meta->{corpus_author}, 'Corpus: author'); |
Akron | b2636cf | 2016-01-26 18:42:44 +0100 | [diff] [blame] | 62 | |
Akron | 12ef05b | 2016-01-31 23:58:53 +0100 | [diff] [blame] | 63 | my $hash = $doc->to_hash; |
| 64 | is($hash->{title}, 'Sommerüberraschung', 'Corpus title'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 65 | is($hash->{sgbrAuthorSex}, 'M', 'additional'); |
Akron | 12ef05b | 2016-01-31 23:58:53 +0100 | [diff] [blame] | 66 | |
Akron | 15e6fa7 | 2016-02-04 15:02:20 +0100 | [diff] [blame] | 67 | # Sgbr specific keywords |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 68 | is($meta->keywords('keywords'), 'sgbrAuthorAgeClass:X sgbrAuthorSex:M sgbrKodex:M'); |
Akron | 15e6fa7 | 2016-02-04 15:02:20 +0100 | [diff] [blame] | 69 | |
Akron | fd0707e | 2016-02-11 22:13:36 +0100 | [diff] [blame] | 70 | |
Akron | b2636cf | 2016-01-26 18:42:44 +0100 | [diff] [blame] | 71 | done_testing; |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 72 | |
| 73 | |
| 74 | __END__ |