Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use utf8; |
| 4 | use Test::More; |
| 5 | use Benchmark ':hireswallclock'; |
Akron | fbf6638 | 2016-07-12 19:44:01 +0200 | [diff] [blame] | 6 | use Mojo::DOM; |
Akron | 3ec0a1c | 2017-01-18 14:41:55 +0100 | [diff] [blame] | 7 | use Mojo::File; |
Akron | fbf6638 | 2016-07-12 19:44:01 +0200 | [diff] [blame] | 8 | use Mojo::ByteStream 'b'; |
| 9 | use Data::Dumper; |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 10 | use lib 'lib', '../lib'; |
| 11 | |
| 12 | use File::Basename 'dirname'; |
| 13 | use File::Spec::Functions 'catdir'; |
| 14 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 15 | use_ok('KorAP::XML::Krill'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 16 | |
| 17 | # WPD/00001 |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 18 | my $path = catdir(dirname(__FILE__), 'corpus/WPD/00001'); |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 19 | ok(my $doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | b3e9ccd | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 20 | like($doc->path, qr!\Q$path\E/!, 'Path'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 21 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 22 | ok($doc = KorAP::XML::Krill->new( path => $path ), 'Load Korap::Document'); |
Nils Diewald | b3e9ccd | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 23 | like($doc->path, qr!\Q$path\E/$!, 'Path'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 24 | |
| 25 | ok($doc->parse, 'Parse document'); |
| 26 | |
| 27 | # Metdata |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 28 | is($doc->text_sigle, 'WPD/AAA/00001', 'ID'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 29 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 30 | my $meta = $doc->meta; |
| 31 | is($meta->{title}, 'A', 'title'); |
Nils Diewald | b3e9ccd | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 32 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 33 | ok(!$meta->{sub_title}, 'subTitle'); |
Nils Diewald | 840c924 | 2014-10-28 19:51:26 +0000 | [diff] [blame] | 34 | is($doc->corpus_sigle, 'WPD', 'corpusID'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 35 | is($meta->{pub_date}, '20050328', 'pubDate'); |
| 36 | is($meta->{pub_place}, 'URL:http://de.wikipedia.org', 'pubPlace'); |
| 37 | is($meta->{text_class}->[0], 'freizeit-unterhaltung', 'TextClass'); |
| 38 | is($meta->{text_class}->[1], 'reisen', 'TextClass'); |
| 39 | is($meta->{text_class}->[2], 'wissenschaft', 'TextClass'); |
| 40 | is($meta->{text_class}->[3], 'populaerwissenschaft', 'TextClass'); |
| 41 | ok(!$meta->{text_class}->[4], 'TextClass'); |
| 42 | is($meta->{author}, 'Ruru; Jens.Ol; Aglarech; u.a.', 'author'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 43 | |
Nils Diewald | b3e9ccd | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 44 | |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 45 | #is($doc->author->[0], 'Ruru', 'author'); |
| 46 | #is($doc->author->[1], 'Jens.Ol', 'author'); |
| 47 | #is($doc->author->[2], 'Aglarech', 'author'); |
| 48 | #ok(!$doc->author->[3], 'author'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 49 | |
| 50 | # Additional information |
Akron | 7e2eb88 | 2017-01-18 17:28:07 +0100 | [diff] [blame^] | 51 | is($meta->{editor}, 'wikipedia.org', 'Editor'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 52 | is($meta->{publisher}, 'Wikipedia', 'Publisher'); |
| 53 | is($meta->{creation_date}, '20050000', 'Creation date'); |
| 54 | ok(!$meta->{text_type}, 'No text_type'); |
| 55 | ok(!$meta->{text_type_art}, 'no text_type art'); |
| 56 | ok(!$meta->{text_type_ref}, 'no text_type ref'); |
| 57 | ok(!$meta->{text_domain}, 'no text_domain'); |
| 58 | ok(!$meta->{text_column}, 'no text_column'); |
| 59 | ok(!$meta->keywords('keywords'), 'no keywords'); |
| 60 | is($meta->keywords('text_class'), 'freizeit-unterhaltung reisen wissenschaft populaerwissenschaft', 'no text classes'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 61 | |
| 62 | #is($doc->coll_title, 'Wikipedia', 'Collection title'); |
| 63 | #is($doc->coll_sub_title, 'Die freie Enzyklopädie', 'Collection subtitle'); |
| 64 | #is($doc->coll_editor, 'wikipedia.org', 'Collection editor'); |
| 65 | #ok(!$doc->coll_author, 'Collection author'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 66 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 67 | # A01/13047 |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 68 | $path = catdir(dirname(__FILE__), 'corpus/A01/13047'); |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 69 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 70 | |
| 71 | ok($doc->parse, 'Parse document'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 72 | $meta = $doc->meta; |
| 73 | is($meta->{title}, 'Fischer und Kolp im Sonnenhügel', 'title'); |
| 74 | |
| 75 | ok(!$meta->{sub_title}, 'subTitle'); |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 76 | is($doc->text_sigle, 'A01/APR/13047', 'ID'); |
Nils Diewald | 840c924 | 2014-10-28 19:51:26 +0000 | [diff] [blame] | 77 | is($doc->corpus_sigle, 'A01', 'corpusID'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 78 | is($meta->{pub_date}, '20010402', 'pubDate'); |
| 79 | ok(!$meta->{pub_place}, 'pubPlace'); |
| 80 | is($meta->{text_class}->[0], 'freizeit-unterhaltung', 'TextClass'); |
| 81 | is($meta->{text_class}->[1], 'vereine-veranstaltungen', 'TextClass'); |
| 82 | ok(!$meta->{text_class}->[2], 'TextClass'); |
| 83 | ok(!$meta->{author}, 'author'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 84 | |
| 85 | # Additional information |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 86 | ok(!$meta->{editor}, 'Editor'); |
| 87 | ok(!$meta->{publisher}, 'Publisher'); |
| 88 | is($meta->{creation_date}, '20010402', 'Creation date'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 89 | #ok(!$doc->coll_title, 'Collection title'); |
| 90 | #ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 91 | #ok(!$doc->coll_editor, 'Collection editor'); |
| 92 | #ok(!$doc->coll_author, 'Collection author'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 93 | ok(!$meta->{text_type}, 'text_type'); |
| 94 | is($meta->{text_type_art}, 'Bericht', 'text_type art'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 95 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 96 | # ERL/0001 |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 97 | $path = catdir(dirname(__FILE__), 'corpus/ERL/00001'); |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 98 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 99 | |
| 100 | ok($doc->parse, 'Parse document'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 101 | |
| 102 | $meta = $doc->meta; |
| 103 | is($meta->{title}, 'Amtsblatt des Landesbezirks Baden [diverse Erlasse]', 'title'); # Amtsblatt des Landesbezirks Baden [diverse Erlasse] |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 104 | # MK2/ERL.00001 |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 105 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 106 | ok(!$meta->{sub_title}, 'subTitle'); |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 107 | is($doc->text_sigle, 'MK2/ERL/00001', 'ID'); |
Nils Diewald | 840c924 | 2014-10-28 19:51:26 +0000 | [diff] [blame] | 108 | is($doc->corpus_sigle, 'MK2', 'corpusID'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 109 | is($meta->{pub_date}, '00000000', 'pubDate'); |
| 110 | is($meta->{pub_place}, 'Karlsruhe', 'pubPlace'); |
| 111 | is($meta->{text_class}->[0], 'politik', 'TextClass'); |
| 112 | is($meta->{text_class}->[1], 'kommunalpolitik', 'TextClass'); |
| 113 | ok(!$meta->{text_class}->[2], 'TextClass'); |
| 114 | ok(!$meta->{author}, 'author'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 115 | |
| 116 | # Additional information |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 117 | ok(!$meta->{editor}, 'Editor'); |
| 118 | is($meta->{publisher}, 'Badenia Verlag und Druckerei', 'Publisher'); |
| 119 | is($meta->{creation_date}, '19600000', 'Creation date'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 120 | |
| 121 | # !!! |
| 122 | # diag 'Non-acceptance of creation date ranges may be temporary'; |
| 123 | |
| 124 | |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 125 | #ok(!$doc->coll_title, 'Collection title'); |
| 126 | #ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 127 | #ok(!$doc->coll_editor, 'Collection editor'); |
| 128 | #ok(!$doc->coll_author, 'Collection author'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 129 | is($meta->{text_type}, 'Erlass', 'text_type'); |
| 130 | ok(!$meta->{text_type_art}, 'text_type art'); |
| 131 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 132 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 133 | # A01/02035-substring |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 134 | $path = catdir(dirname(__FILE__), 'corpus/A00/02035-substring'); |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 135 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 136 | ok($doc->parse, 'Parse document'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 137 | |
| 138 | $meta = $doc->meta; |
| 139 | |
| 140 | is($meta->{title}, 'St. Galler Tagblatt, 11.01.2000, Ressort: TB-RSP (Abk.)', 'title'); # A00/JAN.02035 |
| 141 | ok(!$meta->{sub_title}, 'subTitle'); |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 142 | is($doc->text_sigle, 'A00/JAN/02035', 'ID'); |
Nils Diewald | 840c924 | 2014-10-28 19:51:26 +0000 | [diff] [blame] | 143 | is($doc->corpus_sigle, 'A00', 'corpusID'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 144 | is($meta->{pub_date}, '20000111', 'pubDate'); |
| 145 | ok(!$meta->{pub_place}, 'pubPlace'); |
| 146 | is($meta->{text_class}->[0], 'sport', 'TextClass'); |
| 147 | is($meta->{text_class}->[1], 'ballsport', 'TextClass'); |
| 148 | ok(!$meta->{text_class}->[2], 'TextClass'); |
| 149 | ok(!$meta->{author}, 'author'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 150 | |
| 151 | # Additional information |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 152 | ok(!$meta->{editor}, 'Editor'); |
| 153 | ok(!$meta->{publisher}, 'Publisher'); |
| 154 | is($meta->{creation_date}, "20000111", 'Creation date'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 155 | #ok(!$doc->coll_title, 'Collection title'); |
| 156 | #ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 157 | #ok(!$doc->coll_editor, 'Collection editor'); |
| 158 | #ok(!$doc->coll_author, 'Collection author'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 159 | ok(!$meta->{text_type}, 'text_type'); |
| 160 | is($meta->{text_type_art}, 'Bericht', 'text_type art'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 161 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 162 | # A01/02873-meta |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 163 | $path = catdir(dirname(__FILE__), 'corpus/A00/02873-meta'); |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 164 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 165 | ok($doc->parse, 'Parse document'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 166 | $meta = $doc->meta; |
| 167 | |
| 168 | is($meta->{title}, 'Tradition und Moderne', 'title'); |
| 169 | ok(!$meta->{sub_title}, 'subTitle'); |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 170 | is($doc->text_sigle, 'A00/JAN/02873', 'ID'); |
Nils Diewald | 840c924 | 2014-10-28 19:51:26 +0000 | [diff] [blame] | 171 | is($doc->corpus_sigle, 'A00', 'corpusID'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 172 | is($meta->{pub_date}, '20000113', 'pubDate'); |
| 173 | ok(!$meta->{pub_place}, 'pubPlace'); |
| 174 | is($meta->{text_class}->[0], 'kultur', 'TextClass'); |
| 175 | is($meta->{text_class}->[1], 'film', 'TextClass'); |
| 176 | ok(!$meta->{text_class}->[2], 'TextClass'); |
| 177 | ok(!$meta->{author}, 'author'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 178 | |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 179 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 180 | # Additional information |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 181 | ok(!$meta->{editor}, 'Editor'); |
| 182 | ok(!$meta->{publisher}, 'Publisher'); |
| 183 | is($meta->{creation_date}, "20000113", 'Creation date'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 184 | #ok(!$doc->coll_title, 'Collection title'); |
| 185 | #ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 186 | #ok(!$doc->coll_editor, 'Collection editor'); |
| 187 | #ok(!$doc->coll_author, 'Collection author'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 188 | ok(!$meta->{text_type}, 'text_type'); |
| 189 | is($meta->{text_type_art}, 'Bericht', 'text_type art'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 190 | |
| 191 | |
| 192 | # A01/05663-unbalanced |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 193 | $path = catdir(dirname(__FILE__), 'corpus/A00/05663-unbalanced'); |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 194 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 195 | ok($doc->parse, 'Parse document'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 196 | $meta = $doc->meta; |
| 197 | |
| 198 | is($meta->{title}, 'Mehr Arbeitslose im Dezember', 'title'); |
| 199 | ok(!$meta->{sub_title}, 'subTitle'); |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 200 | is($doc->text_sigle, 'A00/JAN/05663', 'ID'); |
Nils Diewald | 840c924 | 2014-10-28 19:51:26 +0000 | [diff] [blame] | 201 | is($doc->corpus_sigle, 'A00', 'corpusID'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 202 | is($meta->{pub_date}, '20000124', 'pubDate'); |
| 203 | ok(!$meta->{pub_place}, 'pubPlace'); |
| 204 | is($meta->{text_class}->[0], 'gesundheit-ernaehrung', 'TextClass'); |
| 205 | is($meta->{text_class}->[1], 'gesundheit', 'TextClass'); |
| 206 | ok(!$meta->{text_class}->[2], 'TextClass'); |
| 207 | ok(!$meta->{author}, 'author'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 208 | |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 209 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 210 | # Additional information |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 211 | ok(!$meta->{editor}, 'Editor'); |
| 212 | ok(!$meta->{publisher}, 'Publisher'); |
| 213 | is($meta->{creation_date}, "20000124", 'Creation date'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 214 | #ok(!$doc->coll_title, 'Collection title'); |
| 215 | #ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 216 | #ok(!$doc->coll_editor, 'Collection editor'); |
| 217 | #ok(!$doc->coll_author, 'Collection author'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 218 | ok(!$meta->{text_type}, 'text_type'); |
| 219 | is($meta->{text_type_art}, 'Bericht', 'text_type art'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 220 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 221 | # A01/07452-deep |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 222 | $path = catdir(dirname(__FILE__), 'corpus/A00/07452-deep'); |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 223 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 224 | ok($doc->parse, 'Parse document'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 225 | $meta = $doc->meta; |
| 226 | |
| 227 | is($meta->{title}, 'Wil im Dezember 1999', 'title'); |
| 228 | ok(!$meta->{sub_title}, 'subTitle'); |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 229 | is($doc->text_sigle, 'A00/JAN/07452', 'ID'); |
Nils Diewald | 840c924 | 2014-10-28 19:51:26 +0000 | [diff] [blame] | 230 | is($doc->corpus_sigle, 'A00', 'corpusID'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 231 | is($meta->{pub_date}, '20000129', 'pubDate'); |
| 232 | ok(!$meta->{pub_place}, 'pubPlace'); |
| 233 | is($meta->{text_class}->[0], 'politik', 'TextClass'); |
| 234 | is($meta->{text_class}->[1], 'kommunalpolitik', 'TextClass'); |
| 235 | ok(!$meta->{text_class}->[2], 'TextClass'); |
| 236 | ok(!$meta->{author}, 'author'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 237 | |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 238 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 239 | # Additional information |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 240 | ok(!$meta->{editor}, 'Editor'); |
| 241 | ok(!$meta->{publisher}, 'Publisher'); |
| 242 | is($meta->{creation_date}, "20000129", 'Creation date'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 243 | #ok(!$doc->coll_title, 'Collection title'); |
| 244 | #ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 245 | #ok(!$doc->coll_editor, 'Collection editor'); |
| 246 | #ok(!$doc->coll_author, 'Collection author'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 247 | ok(!$meta->{text_type}, 'text_type'); |
| 248 | is($meta->{text_type_art}, 'Bericht', 'text_type art'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 249 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 250 | # ART |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 251 | $path = catdir(dirname(__FILE__), 'corpus/artificial'); |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 252 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 253 | #is($doc->path, $path . '/', 'Path'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 254 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 255 | ok($doc = KorAP::XML::Krill->new( path => $path ), 'Load Korap::Document'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 256 | #is($doc->path, $path . '/', 'Path'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 257 | |
| 258 | ok($doc->parse, 'Parse document'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 259 | $meta = $doc->meta; |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 260 | |
| 261 | # Metdata |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 262 | is($meta->{title}, 'Artificial Title', 'title'); |
| 263 | is($meta->{sub_title}, 'Artificial Subtitle', 'subTitle'); |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 264 | is($doc->text_sigle, 'ART/ABC/00001', 'ID'); |
Nils Diewald | 840c924 | 2014-10-28 19:51:26 +0000 | [diff] [blame] | 265 | is($doc->corpus_sigle, 'ART', 'corpusID'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 266 | is($meta->{pub_date}, '20010402', 'pubDate'); |
| 267 | is($meta->{pub_place}, 'Mannheim', 'pubPlace'); |
| 268 | is($meta->{pub_place_key}, 'DE', 'pubPlace key'); |
| 269 | is($meta->{text_class}->[0], 'freizeit-unterhaltung', 'TextClass'); |
| 270 | is($meta->{text_class}->[1], 'vereine-veranstaltungen', 'TextClass'); |
| 271 | ok(!$meta->{text_class}->[2], 'TextClass'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 272 | #is($doc->author->[0], 'Ruru', 'author'); |
| 273 | #is($doc->author->[1], 'Jens.Ol', 'author'); |
| 274 | #is($doc->author->[2], 'Aglarech', 'author'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 275 | is($meta->{author}, 'Ruru; Jens.Ol; Aglarech; u.a.', 'author'); |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 276 | |
| 277 | # Additional information |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 278 | is($meta->{editor}, 'Nils Diewald', 'Editor'); |
| 279 | is($meta->{publisher}, 'Artificial articles Inc.', 'Publisher'); |
| 280 | is($meta->{creation_date}, '19990601', 'Creation date'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 281 | #is($doc->coll_title, 'Artificial articles', 'Collection title'); |
| 282 | #is($doc->coll_sub_title, 'Best of!', 'Collection subtitle'); |
| 283 | #is($doc->coll_editor, 'Nils Diewald', 'Collection editor'); |
| 284 | #is($doc->coll_author, 'Nils Diewald', 'Collection author'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 285 | is($meta->{text_type}, 'Zeitung: Tageszeitung', 'No text_type'); |
| 286 | is($meta->{text_type_art}, 'Bericht', 'text_type art'); |
| 287 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 288 | |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 289 | # Multipath headers |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 290 | $path = catdir(dirname(__FILE__), 'corpus/VDI/JAN/00001'); |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 291 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | b3e9ccd | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 292 | like($doc->path, qr!\Q$path\E/!, 'Path'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 293 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 294 | ok($doc = KorAP::XML::Krill->new( path => $path ), 'Load Korap::Document'); |
Nils Diewald | b3e9ccd | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 295 | like($doc->path, qr!\Q$path\E/$!, 'Path'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 296 | |
| 297 | ok($doc->parse, 'Parse document'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 298 | $meta = $doc->meta; |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 299 | |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 300 | is($doc->text_sigle, 'VDI14/JAN/00001', 'text sigle'); |
| 301 | is($doc->doc_sigle, 'VDI14/JAN', 'doc sigle'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 302 | is($meta->corpus_sigle, 'VDI14', 'corpus sigle'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 303 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 304 | is($meta->{title}, '10- Zz mit Zahl', 'title'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 305 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 306 | ok(!$meta->{sub_title}, 'subtitle'); |
| 307 | is($meta->{pub_date}, '20140117', 'pubdate'); |
| 308 | is($meta->{pub_place}, 'Düsseldorf', 'pubplace'); |
| 309 | is($meta->{author}, 'Windhövel, Kerstin', 'author'); |
| 310 | is($meta->{publisher}, 'VDI Verlag GmbH', 'publisher'); |
| 311 | ok(!$meta->{editor}, 'editor'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 312 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 313 | ok(!$meta->{text_type}, 'text type'); |
| 314 | ok(!$meta->{text_type_art}, 'text type art'); |
| 315 | ok(!$meta->{text_type_ref}, 'text type ref'); |
| 316 | ok(!$meta->{text_column}, 'text column'); |
| 317 | ok(!$meta->{text_domain}, 'text domain'); |
| 318 | ok(!$meta->{creation_date}, 'creation date'); |
Akron | 6396c30 | 2016-03-18 16:05:39 +0100 | [diff] [blame] | 319 | ok(!$meta->{availability}, 'License'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 320 | ok(!$meta->{pages}, 'Pages'); |
| 321 | ok(!$meta->{file_edition_statement}, 'file edition statement'); |
| 322 | ok(!$meta->{bibl_edition_statement}, 'bibl edition statement'); |
| 323 | is($meta->{reference}, 'VDI nachrichten, 17.01.2014, S. 10; 10- Zz mit Zahl [Ausführliche Zitierung nicht verfügbar]', 'Reference'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 324 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 325 | ok(!$doc->{language}, 'Language'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 326 | # !!! |
| 327 | # diag 'This may be "de" in the future'; |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 328 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 329 | is($meta->{doc_title}, 'VDI nachrichten, Januar 2014', 'Doc title'); |
| 330 | ok(!$meta->{doc_sub_title}, 'Doc Sub title'); |
| 331 | ok(!$meta->{doc_editor}, 'Doc editor'); |
| 332 | ok(!$meta->{doc_author}, 'Doc author'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 333 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 334 | is($meta->{corpus_title}, 'VDI nachrichten', 'Corpus title'); |
| 335 | ok(!$meta->{corpus_sub_title}, 'Corpus Sub title'); |
| 336 | is($meta->{corpus_editor}, 'Verein Deutscher Ingenieure', 'Corpus editor'); |
| 337 | ok(!$meta->{corpus_author}, 'Corpus author'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 338 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 339 | is($meta->keywords('keywords'), '', 'Keywords'); |
| 340 | is($meta->keywords('text_class'), 'Freizeit-Unterhaltung Reisen Politik Ausland', 'Text class'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 341 | |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 342 | # WDD |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 343 | $path = catdir(dirname(__FILE__), 'corpus/WDD/G27/38989'); |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 344 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
Nils Diewald | b3e9ccd | 2016-10-24 15:16:52 +0200 | [diff] [blame] | 345 | like($doc->path, qr!\Q$path\E/!, 'Path'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 346 | ok($doc->parse, 'Parse document'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 347 | $meta = $doc->meta; |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 348 | |
Akron | 1cd5b87 | 2016-03-22 00:23:46 +0100 | [diff] [blame] | 349 | is($doc->text_sigle, 'WDD11/G27/38989', 'text sigle'); |
| 350 | is($doc->doc_sigle, 'WDD11/G27', 'doc sigle'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 351 | is($doc->corpus_sigle, 'WDD11', 'corpus sigle'); |
| 352 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 353 | is($meta->{title}, 'Diskussion:Gunter A. Pilz', 'title'); |
| 354 | ok(!$meta->{sub_title}, 'subtitle'); |
| 355 | is($meta->{pub_date}, '20111029', 'pubdate'); |
| 356 | is($meta->{pub_place}, 'URL:http://de.wikipedia.org', 'pubplace'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 357 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 358 | is($meta->{author}, '€pa, u.a.', 'author'); |
| 359 | is($meta->{publisher}, 'Wikipedia', 'publisher'); |
Akron | 7e2eb88 | 2017-01-18 17:28:07 +0100 | [diff] [blame^] | 360 | is($meta->{editor}, 'wikipedia.org', 'Editor'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 361 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 362 | is($meta->{text_type}, 'Diskussionen zu Enzyklopädie-Artikeln', 'text type'); |
| 363 | ok(!$meta->{text_type_art}, 'text type art'); |
| 364 | ok(!$meta->{text_type_ref}, 'text type ref'); |
| 365 | ok(!$meta->{text_column}, 'text column'); |
| 366 | ok(!$meta->{text_domain}, 'text domain'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 367 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 368 | is($meta->{creation_date}, '20070707', 'creation date'); |
Akron | 6396c30 | 2016-03-18 16:05:39 +0100 | [diff] [blame] | 369 | is($meta->{availability}, 'CC-BY-SA', 'License'); |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 370 | ok(!$meta->{pages}, 'Pages'); |
| 371 | ok(!$meta->{file_edition_statement}, 'file edition statement'); |
| 372 | ok(!$meta->{bibl_edition_statement}, 'bibl edition statement'); |
| 373 | is($meta->{reference}, 'Diskussion:Gunter A. Pilz, In: Wikipedia - URL:http://de.wikipedia.org/wiki/Diskussion:Gunter_A._Pilz: Wikipedia, 2007', 'Reference'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 374 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 375 | is($meta->{language}, 'de', 'Language'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 376 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 377 | is($meta->{doc_title}, 'Wikipedia, Diskussionen zu Artikeln mit Anfangsbuchstabe G, Teil 27', 'Doc title'); |
| 378 | ok(!$meta->{doc_sub_title}, 'Doc Sub title'); |
| 379 | ok(!$meta->{doc_editor}, 'Doc editor'); |
| 380 | ok(!$meta->{doc_author}, 'Doc author'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 381 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 382 | is($meta->{corpus_title}, 'Wikipedia', 'Corpus title'); |
| 383 | ok(!$meta->{corpus_sub_title}, 'Corpus Sub title'); |
| 384 | is($meta->{corpus_editor}, 'wikipedia.org', 'Corpus editor'); |
| 385 | ok(!$meta->{corpus_author}, 'Corpus author'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 386 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 387 | is($meta->keywords('keywords'), '', 'Keywords'); |
| 388 | is($meta->keywords('text_class'), '', 'Text class'); |
Nils Diewald | feccbb1 | 2015-06-18 20:06:45 +0000 | [diff] [blame] | 389 | |
Akron | 35db6e3 | 2016-03-17 22:42:22 +0100 | [diff] [blame] | 390 | is($meta->{availability}, 'CC-BY-SA', 'Availability'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 391 | |
Akron | fbf6638 | 2016-07-12 19:44:01 +0200 | [diff] [blame] | 392 | use_ok('KorAP::XML::Meta::I5'); |
| 393 | |
| 394 | $path = catdir(dirname(__FILE__), 'corpus', 'I5', 'rei-example.i5'); |
| 395 | ok($meta = KorAP::XML::Meta::I5->new, 'Construct meta object'); |
Akron | 3ec0a1c | 2017-01-18 14:41:55 +0100 | [diff] [blame] | 396 | my $dom = Mojo::DOM->new->parse(Mojo::File->new($path)->slurp); |
Akron | fbf6638 | 2016-07-12 19:44:01 +0200 | [diff] [blame] | 397 | ok($meta->parse($dom->at('idsHeader'), 'corpus'), 'Parse corpus header'); |
| 398 | |
| 399 | my $hash = $meta->to_hash; |
| 400 | is($hash->{availability}, 'CC-BY-SA', 'Availability'); |
| 401 | is($hash->{language}, 'de', 'Language'); |
| 402 | is($hash->{corpus_title}, 'Reden und Interviews', 'Corpus title'); |
| 403 | is($hash->{corpus_sigle}, 'REI', 'Corpus Sigle'); |
| 404 | |
| 405 | ok($meta->parse($dom->find('idsHeader')->[1], 'doc'), 'Parse corpus header'); |
| 406 | |
| 407 | $hash = $meta->to_hash; |
| 408 | is($hash->{availability}, 'CC-BY-SA', 'Availability'); |
| 409 | is($hash->{language}, 'de', 'Language'); |
| 410 | is($hash->{corpus_title}, 'Reden und Interviews', 'Corpus title'); |
| 411 | is($hash->{corpus_sigle}, 'REI', 'Corpus Sigle'); |
| 412 | is($hash->{doc_sigle}, 'REI/BNG', 'Document Sigle'); |
| 413 | is($hash->{doc_title}, 'Reden der Bundestagsfraktion Bündnis 90/DIE GRÜNEN, (2002-2006)', 'Document Sigle'); |
| 414 | |
| 415 | ok($meta->parse($dom->find('idsHeader')->[2], 'text'), 'Parse corpus header'); |
| 416 | |
| 417 | $hash = $meta->to_hash; |
| 418 | is($hash->{availability}, 'CC-BY-SA', 'Availability'); |
| 419 | is($hash->{language}, 'de', 'Language'); |
| 420 | is($hash->{corpus_title}, 'Reden und Interviews', 'Corpus title'); |
| 421 | is($hash->{corpus_sigle}, 'REI', 'Corpus Sigle'); |
| 422 | is($hash->{doc_sigle}, 'REI/BNG', 'Document Sigle'); |
| 423 | is($hash->{doc_title}, 'Reden der Bundestagsfraktion Bündnis 90/DIE GRÜNEN, (2002-2006)', 'Document Sigle'); |
| 424 | |
| 425 | is($hash->{text_sigle}, 'REI/BNG/00001'); |
| 426 | is($hash->{title}, 'Energiewirtschaft'); |
| 427 | is($hash->{sub_title}, 'Rede im Deutschen Bundestag am 19.01.2002'); |
| 428 | is($hash->{creation_date}, '20020119'); |
| 429 | is($hash->{pub_date}, '20020119'); |
| 430 | is($hash->{pub_place_key}, 'DE'); |
| 431 | is($hash->{reference}, 'Hustedt, Michaele: Energiewirtschaft. Rede im Deutschen Bundestag am 19.01.2002, Hrsg: Bundestagsfraktion Bündnis 90/DIE GRÜNEN [Ausführliche Zitierung nicht verfügbar]'); |
| 432 | is($hash->{text_class}->[0], 'politik'); |
| 433 | is($hash->{text_class}->[1], 'inland'); |
| 434 | is($hash->{author}, 'Hustedt, Michaele'); |
| 435 | is($hash->{pub_place}, 'Berlin'); |
Akron | a866578 | 2016-01-27 21:47:57 +0100 | [diff] [blame] | 436 | |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 437 | done_testing; |
| 438 | __END__ |
Akron | fbf6638 | 2016-07-12 19:44:01 +0200 | [diff] [blame] | 439 | |
| 440 | |
| 441 | |