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