Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 1 | #!/usr/bin/env perl |
| 2 | # source ~/perl5/perlbrew/etc/bashrc |
| 3 | # perlbrew switch perl-blead@korap |
| 4 | use strict; |
| 5 | use warnings; |
| 6 | use utf8; |
| 7 | use Test::More; |
| 8 | use Benchmark ':hireswallclock'; |
| 9 | use lib 'lib', '../lib'; |
| 10 | |
| 11 | use File::Basename 'dirname'; |
| 12 | use File::Spec::Functions 'catdir'; |
| 13 | |
| 14 | use_ok('KorAP::Document'); |
| 15 | |
| 16 | # WPD/00001 |
| 17 | my $path = catdir(dirname(__FILE__), 'WPD/00001'); |
| 18 | ok(my $doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
| 19 | is($doc->path, $path . '/', 'Path'); |
| 20 | |
| 21 | ok($doc = KorAP::Document->new( path => $path ), 'Load Korap::Document'); |
| 22 | is($doc->path, $path . '/', 'Path'); |
| 23 | |
| 24 | ok($doc->parse, 'Parse document'); |
| 25 | |
| 26 | # Metdata |
| 27 | is($doc->title, 'A', 'title'); |
| 28 | ok(!$doc->sub_title, 'subTitle'); |
| 29 | is($doc->id, 'WPD_AAA.00001', 'ID'); |
| 30 | is($doc->corpus_id, 'WPD', 'corpusID'); |
| 31 | is($doc->pub_date, '20050328', 'pubDate'); |
| 32 | is($doc->pub_place, 'URL:http://de.wikipedia.org', 'pubPlace'); |
| 33 | is($doc->text_class->[0], 'freizeit-unterhaltung', 'TextClass'); |
| 34 | is($doc->text_class->[1], 'reisen', 'TextClass'); |
| 35 | is($doc->text_class->[2], 'wissenschaft', 'TextClass'); |
| 36 | is($doc->text_class->[3], 'populaerwissenschaft', 'TextClass'); |
| 37 | ok(!$doc->text_class->[4], 'TextClass'); |
| 38 | is($doc->author->[0], 'Ruru', 'author'); |
| 39 | is($doc->author->[1], 'Jens.Ol', 'author'); |
| 40 | is($doc->author->[2], 'Aglarech', 'author'); |
| 41 | ok(!$doc->author->[3], 'author'); |
| 42 | |
| 43 | # Additional information |
| 44 | ok(!$doc->editor, 'Editor'); |
| 45 | is($doc->publisher, 'Wikipedia', 'Publisher'); |
| 46 | is($doc->creation_date, '20050000', 'Creation date'); |
| 47 | is($doc->coll_title, 'Wikipedia', 'Collection title'); |
| 48 | is($doc->coll_sub_title, 'Die freie Enzyklopädie', 'Collection subtitle'); |
| 49 | is($doc->coll_editor, 'wikipedia.org', 'Collection editor'); |
| 50 | ok(!$doc->coll_author, 'Collection author'); |
| 51 | ok(!$doc->text_type, 'No text_type'); |
| 52 | ok(!$doc->text_type_art, 'text_type art'); |
| 53 | |
| 54 | # BRZ13/00001 |
| 55 | $path = catdir(dirname(__FILE__), 'BRZ13/00001'); |
| 56 | ok($doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
| 57 | |
| 58 | ok($doc->parse, 'Parse document'); |
| 59 | is($doc->title, 'Sexueller Missbrauch –„Das schreiende Kind steckt noch tief in mir“', 'title'); |
| 60 | ok(!$doc->sub_title, 'subTitle'); |
| 61 | is($doc->id, 'BRZ13_APR.00001', 'ID'); |
| 62 | is($doc->corpus_id, 'BRZ13', 'corpusID'); |
| 63 | is($doc->pub_date, '20130402', 'pubDate'); |
| 64 | is($doc->pub_place, 'Braunschweig', 'pubPlace'); |
| 65 | is($doc->text_class->[0], 'staat-gesellschaft', 'TextClass'); |
| 66 | is($doc->text_class->[1], 'familie-geschlecht', 'TextClass'); |
| 67 | ok(!$doc->text_class->[2], 'TextClass'); |
| 68 | ok(!$doc->author->[0], 'author'); |
| 69 | |
| 70 | # Additional information |
| 71 | ok(!$doc->editor, 'Editor'); |
| 72 | is($doc->publisher, 'Braunschweiger Zeitungsverlag, Druckhaus Albert Limbach GmbH & Co. KG', 'Publisher'); |
| 73 | is($doc->creation_date, '20130402', 'Creation date'); |
| 74 | is($doc->coll_title, 'Braunschweiger Zeitung', 'Collection title'); |
| 75 | ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 76 | ok(!$doc->coll_editor, 'Collection editor'); |
| 77 | ok(!$doc->coll_author, 'Collection author'); |
| 78 | is($doc->text_type, 'Zeitung: Tageszeitung', 'text_type'); |
| 79 | ok(!$doc->text_type_art, 'text_type art'); |
| 80 | |
| 81 | # A01/13047 |
| 82 | $path = catdir(dirname(__FILE__), 'A01/13047'); |
| 83 | ok($doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
| 84 | |
| 85 | ok($doc->parse, 'Parse document'); |
| 86 | is($doc->title, 'Fischer und Kolp im Sonnenhügel', 'title'); |
| 87 | ok(!$doc->sub_title, 'subTitle'); |
| 88 | is($doc->id, 'A01_APR.13047', 'ID'); |
| 89 | is($doc->corpus_id, 'A01', 'corpusID'); |
| 90 | is($doc->pub_date, '20010402', 'pubDate'); |
| 91 | ok(!$doc->pub_place, 'pubPlace'); |
| 92 | is($doc->text_class->[0], 'freizeit-unterhaltung', 'TextClass'); |
| 93 | is($doc->text_class->[1], 'vereine-veranstaltungen', 'TextClass'); |
| 94 | ok(!$doc->text_class->[2], 'TextClass'); |
| 95 | ok(!$doc->author->[0], 'author'); |
| 96 | |
| 97 | |
| 98 | # Additional information |
| 99 | ok(!$doc->editor, 'Editor'); |
| 100 | ok(!$doc->publisher, 'Publisher'); |
| 101 | is($doc->creation_date, '20010402', 'Creation date'); |
| 102 | ok(!$doc->coll_title, 'Collection title'); |
| 103 | ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 104 | ok(!$doc->coll_editor, 'Collection editor'); |
| 105 | ok(!$doc->coll_author, 'Collection author'); |
| 106 | ok(!$doc->text_type, 'text_type'); |
| 107 | is($doc->text_type_art, 'Bericht', 'text_type art'); |
| 108 | |
| 109 | |
| 110 | # ERL/0001 |
| 111 | $path = catdir(dirname(__FILE__), 'ERL/00001'); |
| 112 | ok($doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
| 113 | |
| 114 | ok($doc->parse, 'Parse document'); |
| 115 | is($doc->title, 'Amtsblatt des Landesbezirks Baden [diverse Erlasse]', 'title'); |
| 116 | ok(!$doc->sub_title, 'subTitle'); |
| 117 | is($doc->id, 'MK2_ERL.00001', 'ID'); |
| 118 | is($doc->corpus_id, 'MK2', 'corpusID'); |
| 119 | is($doc->pub_date, '00000000', 'pubDate'); |
| 120 | is($doc->pub_place, 'Karlsruhe', 'pubPlace'); |
| 121 | is($doc->text_class->[0], 'politik', 'TextClass'); |
| 122 | is($doc->text_class->[1], 'kommunalpolitik', 'TextClass'); |
| 123 | ok(!$doc->text_class->[2], 'TextClass'); |
| 124 | ok(!$doc->author->[0], 'author'); |
| 125 | |
| 126 | # Additional information |
| 127 | ok(!$doc->editor, 'Editor'); |
| 128 | is($doc->publisher, 'Badenia Verlag und Druckerei', 'Publisher'); |
| 129 | ok(!$doc->creation_date, 'Creation date'); |
| 130 | diag 'Non-acceptance of creation date ranges is temporary'; |
| 131 | ok(!$doc->coll_title, 'Collection title'); |
| 132 | ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 133 | ok(!$doc->coll_editor, 'Collection editor'); |
| 134 | ok(!$doc->coll_author, 'Collection author'); |
| 135 | is($doc->text_type, 'Erlass', 'text_type'); |
| 136 | ok(!$doc->text_type_art, 'text_type art'); |
| 137 | |
| 138 | |
| 139 | # A01/02035-substring |
| 140 | $path = catdir(dirname(__FILE__), 'A01/02035-substring'); |
| 141 | ok($doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
| 142 | |
| 143 | ok($doc->parse, 'Parse document'); |
| 144 | ok(!$doc->title, 'title'); |
| 145 | ok(!$doc->sub_title, 'subTitle'); |
| 146 | is($doc->id, 'A00_JAN.02035', 'ID'); |
| 147 | is($doc->corpus_id, 'A00', 'corpusID'); |
| 148 | is($doc->pub_date, '20000111', 'pubDate'); |
| 149 | ok(!$doc->pub_place, 'pubPlace'); |
| 150 | is($doc->text_class->[0], 'sport', 'TextClass'); |
| 151 | is($doc->text_class->[1], 'ballsport', 'TextClass'); |
| 152 | ok(!$doc->text_class->[2], 'TextClass'); |
| 153 | ok(!$doc->author->[0], 'author'); |
| 154 | |
| 155 | # Additional information |
| 156 | ok(!$doc->editor, 'Editor'); |
| 157 | ok(!$doc->publisher, 'Publisher'); |
| 158 | is($doc->creation_date, "20000111", 'Creation date'); |
| 159 | ok(!$doc->coll_title, 'Collection title'); |
| 160 | ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 161 | ok(!$doc->coll_editor, 'Collection editor'); |
| 162 | ok(!$doc->coll_author, 'Collection author'); |
| 163 | ok(!$doc->text_type, 'text_type'); |
| 164 | is($doc->text_type_art, 'Bericht', 'text_type art'); |
| 165 | |
| 166 | |
| 167 | # A01/02873-meta |
| 168 | $path = catdir(dirname(__FILE__), 'A01/02873-meta'); |
| 169 | ok($doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
| 170 | |
| 171 | ok($doc->parse, 'Parse document'); |
| 172 | is($doc->title, 'Tradition und Moderne', 'title'); |
| 173 | ok(!$doc->sub_title, 'subTitle'); |
| 174 | is($doc->id, 'A00_JAN.02873', 'ID'); |
| 175 | is($doc->corpus_id, 'A00', 'corpusID'); |
| 176 | is($doc->pub_date, '20000113', 'pubDate'); |
| 177 | ok(!$doc->pub_place, 'pubPlace'); |
| 178 | is($doc->text_class->[0], 'kultur', 'TextClass'); |
| 179 | is($doc->text_class->[1], 'film', 'TextClass'); |
| 180 | ok(!$doc->text_class->[2], 'TextClass'); |
| 181 | ok(!$doc->author->[0], 'author'); |
| 182 | |
| 183 | # Additional information |
| 184 | ok(!$doc->editor, 'Editor'); |
| 185 | ok(!$doc->publisher, 'Publisher'); |
| 186 | is($doc->creation_date, "20000113", 'Creation date'); |
| 187 | ok(!$doc->coll_title, 'Collection title'); |
| 188 | ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 189 | ok(!$doc->coll_editor, 'Collection editor'); |
| 190 | ok(!$doc->coll_author, 'Collection author'); |
| 191 | ok(!$doc->text_type, 'text_type'); |
| 192 | is($doc->text_type_art, 'Bericht', 'text_type art'); |
| 193 | |
| 194 | |
| 195 | # A01/05663-unbalanced |
| 196 | $path = catdir(dirname(__FILE__), 'A01/05663-unbalanced'); |
| 197 | ok($doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
| 198 | |
| 199 | ok($doc->parse, 'Parse document'); |
| 200 | is($doc->title, 'Mehr Arbeitslose im Dezember', 'title'); |
| 201 | ok(!$doc->sub_title, 'subTitle'); |
| 202 | is($doc->id, 'A00_JAN.05663', 'ID'); |
| 203 | is($doc->corpus_id, 'A00', 'corpusID'); |
| 204 | is($doc->pub_date, '20000124', 'pubDate'); |
| 205 | ok(!$doc->pub_place, 'pubPlace'); |
| 206 | is($doc->text_class->[0], 'gesundheit-ernaehrung', 'TextClass'); |
| 207 | is($doc->text_class->[1], 'gesundheit', 'TextClass'); |
| 208 | ok(!$doc->text_class->[2], 'TextClass'); |
| 209 | ok(!$doc->author->[0], 'author'); |
| 210 | |
| 211 | # Additional information |
| 212 | ok(!$doc->editor, 'Editor'); |
| 213 | ok(!$doc->publisher, 'Publisher'); |
| 214 | is($doc->creation_date, "20000124", 'Creation date'); |
| 215 | ok(!$doc->coll_title, 'Collection title'); |
| 216 | ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 217 | ok(!$doc->coll_editor, 'Collection editor'); |
| 218 | ok(!$doc->coll_author, 'Collection author'); |
| 219 | ok(!$doc->text_type, 'text_type'); |
| 220 | is($doc->text_type_art, 'Bericht', 'text_type art'); |
| 221 | |
| 222 | |
| 223 | |
| 224 | # A01/07452-deep |
| 225 | $path = catdir(dirname(__FILE__), 'A01/07452-deep'); |
| 226 | ok($doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
| 227 | |
| 228 | ok($doc->parse, 'Parse document'); |
| 229 | is($doc->title, 'Wil im Dezember 1999', 'title'); |
| 230 | ok(!$doc->sub_title, 'subTitle'); |
| 231 | is($doc->id, 'A00_JAN.07452', 'ID'); |
| 232 | is($doc->corpus_id, 'A00', 'corpusID'); |
| 233 | is($doc->pub_date, '20000129', 'pubDate'); |
| 234 | ok(!$doc->pub_place, 'pubPlace'); |
| 235 | is($doc->text_class->[0], 'politik', 'TextClass'); |
| 236 | is($doc->text_class->[1], 'kommunalpolitik', 'TextClass'); |
| 237 | ok(!$doc->text_class->[2], 'TextClass'); |
| 238 | ok(!$doc->author->[0], 'author'); |
| 239 | |
| 240 | # Additional information |
| 241 | ok(!$doc->editor, 'Editor'); |
| 242 | ok(!$doc->publisher, 'Publisher'); |
| 243 | is($doc->creation_date, "20000129", 'Creation date'); |
| 244 | ok(!$doc->coll_title, 'Collection title'); |
| 245 | ok(!$doc->coll_sub_title, 'Collection subtitle'); |
| 246 | ok(!$doc->coll_editor, 'Collection editor'); |
| 247 | ok(!$doc->coll_author, 'Collection author'); |
| 248 | ok(!$doc->text_type, 'text_type'); |
| 249 | is($doc->text_type_art, 'Bericht', 'text_type art'); |
| 250 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 251 | # ART |
| 252 | $path = catdir(dirname(__FILE__), 'artificial'); |
| 253 | ok($doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document'); |
| 254 | is($doc->path, $path . '/', 'Path'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 255 | |
Nils Diewald | 98767bb | 2014-04-25 20:31:19 +0000 | [diff] [blame] | 256 | ok($doc = KorAP::Document->new( path => $path ), 'Load Korap::Document'); |
| 257 | is($doc->path, $path . '/', 'Path'); |
| 258 | |
| 259 | ok($doc->parse, 'Parse document'); |
| 260 | |
| 261 | # Metdata |
| 262 | is($doc->title, 'Artificial Title', 'title'); |
| 263 | is($doc->sub_title, 'Artificial Subtitle', 'subTitle'); |
| 264 | is($doc->id, 'ART_00001', 'ID'); |
| 265 | is($doc->corpus_id, 'ART', 'corpusID'); |
| 266 | is($doc->pub_date, '20010402', 'pubDate'); |
| 267 | is($doc->pub_place, 'Mannheim', 'pubPlace'); |
| 268 | is($doc->text_class->[0], 'freizeit-unterhaltung', 'TextClass'); |
| 269 | is($doc->text_class->[1], 'vereine-veranstaltungen', 'TextClass'); |
| 270 | ok(!$doc->text_class->[2], 'TextClass'); |
| 271 | is($doc->author->[0], 'Ruru', 'author'); |
| 272 | is($doc->author->[1], 'Jens.Ol', 'author'); |
| 273 | is($doc->author->[2], 'Aglarech', 'author'); |
| 274 | ok(!$doc->author->[3], 'author'); |
| 275 | |
| 276 | # Additional information |
| 277 | is($doc->editor, 'Nils Diewald', 'Editor'); |
| 278 | is($doc->publisher, 'Artificial articles Inc.', 'Publisher'); |
| 279 | is($doc->creation_date, '19990601', 'Creation date'); |
| 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'); |
| 284 | is($doc->text_type, 'Zeitung: Tageszeitung', 'No text_type'); |
| 285 | is($doc->text_type_art, 'Bericht', 'text_type art'); |
Nils Diewald | 8e323ee | 2014-04-23 17:28:14 +0000 | [diff] [blame] | 286 | |
| 287 | done_testing; |
| 288 | __END__ |