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