Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | use utf8; |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 5 | use JSON::XS; |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 6 | use Test::More; |
| 7 | use Scalar::Util qw/weaken/; |
| 8 | use Data::Dumper; |
Akron | 151676d | 2016-03-14 20:12:14 +0100 | [diff] [blame] | 9 | use lib 't/annotation'; |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 10 | use TestInit; |
| 11 | use File::Basename 'dirname'; |
| 12 | use File::Spec::Functions 'catdir'; |
| 13 | |
| 14 | |
| 15 | my $path = catdir(dirname(__FILE__), 'corpus', 'doc', '0001'); |
| 16 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 17 | ok(my $doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 18 | ok($doc->parse, 'Parse document'); |
Nils Diewald | 0e48977 | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 19 | like($doc->path, qr!\Q$path\E/!, 'Path'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 20 | |
| 21 | # Metdata |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 22 | is($doc->text_sigle, 'Corpus/Doc/0001', 'ID-text'); |
| 23 | is($doc->doc_sigle, 'Corpus/Doc', 'ID-doc'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 24 | is($doc->corpus_sigle, 'Corpus', 'ID-corpus'); |
| 25 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 26 | my $meta = $doc->meta; |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 27 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 28 | is($meta->{title}, 'Beispiel Text', 'title'); |
| 29 | is($meta->{sub_title}, 'Beispiel Text Untertitel', 'title'); |
| 30 | is($meta->{pub_date}, '20010402', 'Publication date'); |
| 31 | is($meta->{pub_place}, 'Mannheim', 'Publication place'); |
| 32 | is($meta->{author}, 'Mustermann, Max', 'Author'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 33 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 34 | is($meta->{publisher}, 'Artificial articles Inc.', 'Publisher'); |
| 35 | is($meta->{editor}, 'Monika Mustermann', 'Editor'); |
| 36 | is($meta->{text_type}, 'Zeitung: Tageszeitung', 'Text Type'); |
| 37 | is($meta->{text_type_art}, 'Bericht', 'Text Type Art'); |
| 38 | is($meta->{text_type_ref}, 'Aphorismen', 'Text Type Ref'); |
| 39 | ok(!$meta->{text_column}, 'Text Column'); |
| 40 | ok(!$meta->{text_domain}, 'Text Domain'); |
| 41 | is($meta->{creation_date}, '19990601', 'Creation Date'); |
| 42 | ok(!$meta->{license}, 'License'); |
| 43 | ok(!$meta->{pages}, 'Pages'); |
| 44 | ok(!$meta->{file_edition_statement}, 'File Edition Statement'); |
| 45 | ok(!$meta->{bibl_edition_statement}, 'Bibl Edition Statement'); |
| 46 | ok(!$meta->{reference}, 'Reference'); |
| 47 | is($meta->{language}, 'de', 'Language'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 48 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 49 | is($meta->{doc_title}, 'Beispiel Dokument', 'Doc: title'); |
| 50 | ok(!$meta->{doc_sub_title}, 'Doc: subtitle'); |
| 51 | ok(!$meta->{doc_editor}, 'Doc: editor'); |
| 52 | ok(!$meta->{doc_author}, 'Doc: author'); |
| 53 | |
| 54 | is($meta->{corpus_title}, 'Werke von Beispiel', 'Corpus: title'); |
| 55 | ok(!$meta->{corpus_sub_title}, 'Corpus: subtitle'); |
| 56 | is($meta->{corpus_editor}, 'Mustermann, Monika', 'Corpus: editor'); |
| 57 | is($meta->{corpus_author}, 'Mustermann, Max', 'Corpus: author'); |
| 58 | |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 59 | |
| 60 | done_testing; |
| 61 | |
| 62 | __END__ |