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