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