Simplified and modularized metadata processing

Change-Id: I63e78fd5994126c954263324bcfc2fd9d51e39ea
diff --git a/t/sgbr/meta_ids.t b/t/sgbr/meta_ids.t
index 4128f5d..b040e09 100644
--- a/t/sgbr/meta_ids.t
+++ b/t/sgbr/meta_ids.t
@@ -11,7 +11,8 @@
 my $path = catdir(dirname(__FILE__), 'CMC-TSK', '2014-09', '2843');
 
 ok(my $doc = KorAP::XML::Krill->new(
-  path => $path . '/'
+  path => $path . '/',
+  meta_type => 'Sgbr'
 ), 'Create Document');
 
 ok($doc->parse, 'Parse document');
@@ -24,61 +25,62 @@
 is($doc->doc_sigle, 'CMC-TSK_2014-09', 'ID-doc');
 is($doc->corpus_sigle, 'CMC-TSK', 'ID-corpus');
 
-is($doc->title, '@ Koelle_am_Rhing 10:18', 'title');
+my $meta = $doc->meta;
 
-ok(!$doc->sub_title, 'no subtitle');
+is($meta->{title}, '@ Koelle_am_Rhing 10:18', 'title');
 
-is($doc->publisher, 'tagesschau.de', 'Publisher');
+ok(!$meta->{sub_title}, 'no subtitle');
 
-is($doc->pub_date, '20140930');
+is($meta->{publisher}, 'tagesschau.de', 'Publisher');
 
-ok(!$doc->pub_place, 'No pub place');
+is($meta->{pub_date}, '20140930');
 
-is($doc->doc_title, 'Korpus zur Beobachtung des Schreibgebrauchs im Deutschen', 'Doc title');
-is($doc->doc_sub_title, 'Subkorpus Internettexte, Subkorpus Leserkommentare Tagesschau, Subkorpus September 2014, Subkorpus Beispielauszug', 'Doc Sub title');
+ok(!$meta->{pub_place}, 'No pub place');
 
-is($doc->store('funder'), 'Bundesministerium für Bildung und Forschung', 'Funder');
+is($meta->{doc_title}, 'Korpus zur Beobachtung des Schreibgebrauchs im Deutschen', 'Doc title');
+is($meta->{doc_sub_title}, 'Subkorpus Internettexte, Subkorpus Leserkommentare Tagesschau, Subkorpus September 2014, Subkorpus Beispielauszug', 'Doc Sub title');
 
-is($doc->author, 'privat23', 'Author');
-ok(!$doc->store('sgbrAuthorSex'), 'No Sex');
-ok(!$doc->store('sgbrKodex'), 'No kodex');
-is($doc->reference, 'http://meta.tagesschau.de/node/090285#comment-1732187', 'Publace ref');
+is($meta->{'funder'}, 'Bundesministerium für Bildung und Forschung', 'Funder');
 
-is($doc->keywords_string, '');
+is($meta->{author}, 'privat23', 'Author');
+ok(!$meta->{'sgbr_author_sex'}, 'No Sex');
+ok(!$meta->{'sgbr_kodex'}, 'No kodex');
+is($meta->{reference}, 'http://meta.tagesschau.de/node/090285#comment-1732187', 'Publace ref');
 
-is($doc->language, 'de', 'Language');
+is($meta->keywords('keywords'), '');
 
-ok(!$doc->editor, 'Editor');
+is($meta->{language}, 'de', 'Language');
 
-ok(!$doc->text_type, 'Text Type');
-ok(!$doc->text_type_art, 'Text Type Art');
-ok(!$doc->text_type_ref, 'Text Type Ref');
-ok(!$doc->text_column, 'Text Column');
-ok(!$doc->text_domain, 'Text Domain');
-ok(!$doc->creation_date, 'Creation Date');
-ok(!$doc->license, 'License');
-ok(!$doc->pages, 'Pages');
-ok(!$doc->file_edition_statement, 'File Edition Statement');
-ok(!$doc->bibl_edition_statement, 'Bibl Edition Statement');
+ok(!$meta->{editor}, 'Editor');
 
-ok(!$doc->doc_editor, 'Doc: editor');
-ok(!$doc->doc_author, 'Doc: author');
+ok(!$meta->{text_type}, 'Text Type');
+ok(!$meta->{text_type_art}, 'Text Type Art');
+ok(!$meta->{text_type_ref}, 'Text Type Ref');
+ok(!$meta->{text_column}, 'Text Column');
+ok(!$meta->{text_domain}, 'Text Domain');
+ok(!$meta->{creation_date}, 'Creation Date');
+ok(!$meta->{license}, 'License');
+ok(!$meta->{pages}, 'Pages');
+ok(!$meta->{file_edition_statement}, 'File Edition Statement');
+ok(!$meta->{bibl_edition_statement}, 'Bibl Edition Statement');
 
-ok(!$doc->corpus_title, 'Corpus: title');
-ok(!$doc->corpus_sub_title, 'Corpus: subtitle');
-ok(!$doc->corpus_editor, 'Corpus: editor');
-ok(!$doc->corpus_author, 'Corpus: author');
+ok(!$meta->{doc_editor}, 'Doc: editor');
+ok(!$meta->{doc_author}, 'Doc: author');
+
+ok(!$meta->{corpus_title}, 'Corpus: title');
+ok(!$meta->{corpus_sub_title}, 'Corpus: subtitle');
+ok(!$meta->{corpus_editor}, 'Corpus: editor');
+ok(!$meta->{corpus_author}, 'Corpus: author');
 
 my $hash = $doc->to_hash;
 is($hash->{title}, '@ Koelle_am_Rhing 10:18', 'Corpus title');
 
-
 # Second document
-
 $path = catdir(dirname(__FILE__), 'CMC-TSK', '2014-09', '3401');
 
 ok($doc = KorAP::XML::Krill->new(
-  path => $path . '/'
+  path => $path . '/',
+  meta_type => 'Sgbr'
 ), 'Create Document');
 
 ok($doc->parse, 'Parse document');
@@ -91,51 +93,53 @@
 is($doc->doc_sigle, 'CMC-TSK_2014-09', 'ID-doc');
 is($doc->corpus_sigle, 'CMC-TSK', 'ID-corpus');
 
-is($doc->title, '@fitnessfrosch', 'title');
 
-ok(!$doc->sub_title, 'no subtitle');
+$meta = $doc->meta;
+is($meta->{title}, '@fitnessfrosch', 'title');
 
-is($doc->publisher, 'tagesschau.de', 'Publisher');
+ok(!$meta->{sub_title}, 'no subtitle');
 
-is($doc->pub_date, '20141001');
-is($doc->store('sgbrDate'), '2014-10-01 00:50:00');
+is($meta->{publisher}, 'tagesschau.de', 'Publisher');
 
-ok(!$doc->pub_place, 'No pub place');
+is($meta->{pub_date}, '20141001');
+is($meta->{'sgbr_date'}, '2014-10-01 00:50:00');
 
-is($doc->doc_title, 'Korpus zur Beobachtung des Schreibgebrauchs im Deutschen', 'Doc title');
-is($doc->doc_sub_title, 'Subkorpus Internettexte, Subkorpus Leserkommentare Tagesschau, Subkorpus September 2014, Subkorpus Beispielauszug', 'Doc Sub title');
+ok(!$meta->{pub_place}, 'No pub place');
 
-is($doc->store('funder'), 'Bundesministerium für Bildung und Forschung', 'Funder');
+is($meta->{doc_title}, 'Korpus zur Beobachtung des Schreibgebrauchs im Deutschen', 'Doc title');
+is($meta->{doc_sub_title}, 'Subkorpus Internettexte, Subkorpus Leserkommentare Tagesschau, Subkorpus September 2014, Subkorpus Beispielauszug', 'Doc Sub title');
 
-is($doc->author, 'weltoffen', 'Author');
-ok(!$doc->store('sgbrAuthorSex'), 'No Sex');
-ok(!$doc->store('sgbrKodex'), 'No kodex');
-is($doc->reference, 'http://meta.tagesschau.de/node/090308#comment-1732754', 'Publace ref');
+is($meta->{'funder'}, 'Bundesministerium für Bildung und Forschung', 'Funder');
 
-is($doc->keywords_string, '');
+is($meta->{author}, 'weltoffen', 'Author');
+ok(!$meta->{'sgbr_author_sex'}, 'No Sex');
+ok(!$meta->{'sgbr_kodex'}, 'No kodex');
+is($meta->{reference}, 'http://meta.tagesschau.de/node/090308#comment-1732754', 'Publace ref');
 
-is($doc->language, 'de', 'Language');
+is($meta->keywords('keywords'), '');
 
-ok(!$doc->editor, 'Editor');
+is($meta->{language}, 'de', 'Language');
 
-ok(!$doc->text_type, 'Text Type');
-ok(!$doc->text_type_art, 'Text Type Art');
-ok(!$doc->text_type_ref, 'Text Type Ref');
-ok(!$doc->text_column, 'Text Column');
-ok(!$doc->text_domain, 'Text Domain');
-ok(!$doc->creation_date, 'Creation Date');
-ok(!$doc->license, 'License');
-ok(!$doc->pages, 'Pages');
-ok(!$doc->file_edition_statement, 'File Edition Statement');
-ok(!$doc->bibl_edition_statement, 'Bibl Edition Statement');
+ok(!$meta->{editor}, 'Editor');
 
-ok(!$doc->doc_editor, 'Doc: editor');
-ok(!$doc->doc_author, 'Doc: author');
+ok(!$meta->{text_type}, 'Text Type');
+ok(!$meta->{text_type_art}, 'Text Type Art');
+ok(!$meta->{text_type_ref}, 'Text Type Ref');
+ok(!$meta->{text_column}, 'Text Column');
+ok(!$meta->{text_domain}, 'Text Domain');
+ok(!$meta->{creation_date}, 'Creation Date');
+ok(!$meta->{license}, 'License');
+ok(!$meta->{pages}, 'Pages');
+ok(!$meta->{file_edition_statement}, 'File Edition Statement');
+ok(!$meta->{bibl_edition_statement}, 'Bibl Edition Statement');
 
-ok(!$doc->corpus_title, 'Corpus: title');
-ok(!$doc->corpus_sub_title, 'Corpus: subtitle');
-ok(!$doc->corpus_editor, 'Corpus: editor');
-ok(!$doc->corpus_author, 'Corpus: author');
+ok(!$meta->{doc_editor}, 'Doc: editor');
+ok(!$meta->{doc_author}, 'Doc: author');
+
+ok(!$meta->{corpus_title}, 'Corpus: title');
+ok(!$meta->{corpus_sub_title}, 'Corpus: subtitle');
+ok(!$meta->{corpus_editor}, 'Corpus: editor');
+ok(!$meta->{corpus_author}, 'Corpus: author');
 
 $hash = $doc->to_hash;
 is($hash->{title}, '@fitnessfrosch', 'Corpus title');