Finished test suite

Change-Id: I05969aba1dab4802822499e0fda8e7a1a21fa693
diff --git a/t/real/bzk.t b/t/real/bzk.t
new file mode 100644
index 0000000..3b39b25
--- /dev/null
+++ b/t/real/bzk.t
@@ -0,0 +1,270 @@
+#!/usr/bin/env perl
+# source ~/perl5/perlbrew/etc/bashrc
+# perlbrew switch perl-blead@korap
+use strict;
+use warnings;
+use Test::More;
+use Data::Dumper;
+use JSON::XS;
+
+use Benchmark qw/:hireswallclock/;
+
+my $t = Benchmark->new;
+
+use utf8;
+use lib 'lib', '../lib';
+
+use File::Basename 'dirname';
+use File::Spec::Functions 'catdir';
+
+use_ok('KorAP::Document');
+
+my $path = catdir(dirname(__FILE__), '../corpus/BZK/D59/00001');
+
+ok(my $doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document');
+ok($doc->parse, 'Parse document');
+
+is($doc->text_sigle, 'BZK_D59.00001', 'Correct text sigle');
+is($doc->doc_sigle, 'BZK_D59', 'Correct document sigle');
+is($doc->corpus_sigle, 'BZK', 'Correct corpus sigle');
+
+is($doc->title, 'Unser gemeinsames Werk wird siegreich sein', 'Title');
+ok(!$doc->sub_title, 'No SubTitle');
+ok(!$doc->author, 'Author');
+ok(!$doc->editor, 'Editor');
+is($doc->pub_place, 'Berlin', 'PubPlace');
+ok(!$doc->publisher, 'Publisher');
+
+is($doc->text_type, 'Zeitung: Tageszeitung', 'Correct Text Type');
+
+ok(!$doc->text_type_art, 'Correct Text Type Art');
+is($doc->text_type_ref, 'Tageszeitung', 'Correct Text Type Ref');
+is($doc->text_domain, 'Politik', 'Correct Text Domain');
+is($doc->text_column, 'POLITIK', 'Correct Text Column');
+is($doc->text_class->[0], 'politik', 'Correct Text Class');
+is($doc->text_class->[1], 'ausland', 'Correct Text Class');
+ok(!$doc->text_class->[2], 'Correct Text Class');
+
+is($doc->pub_date, '19590101', 'Creation date');
+is($doc->creation_date, '19590101', 'Creation date');
+is($doc->license, 'ACA-NC-LC', 'License');
+ok(!$doc->pages, 'Pages');
+
+ok(!$doc->file_edition_statement, 'File Statement');
+ok(!$doc->bibl_edition_statement, 'Bibl Statement');
+
+is($doc->reference . "\n", <<'REF', 'Reference');
+Neues Deutschland, [Tageszeitung], 01.01.1959, Jg. 14, Berliner Ausgabe, S. 1. - Sachgebiet: Politik, Originalressort: POLITIK; Unser gemeinsames Werk wird siegreich sein
+REF
+is($doc->language, 'de', 'Language');
+
+is($doc->corpus_title, 'Bonner Zeitungskorpus', 'Correct Corpus title');
+ok(!$doc->corpus_sub_title, 'Correct Corpus sub title');
+ok(!$doc->corpus_author, 'Correct Corpus author');
+ok(!$doc->corpus_editor, 'Correct Corpus editor');
+
+is($doc->doc_title, 'Neues Deutschland', 'Correct Doc title');
+is($doc->doc_sub_title, 'Organ des Zentralkomitees der Sozialistischen Einheitspartei Deutschlands', 'Correct Doc sub title');
+ok(!$doc->doc_author, 'Correct Doc author');
+ok(!$doc->doc_editor, 'Correct doc editor');
+
+# Tokenization
+use_ok('KorAP::Tokenizer');
+
+my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/);
+
+# Get tokenization
+my $tokens = KorAP::Tokenizer->new(
+  path => $doc->path,
+  doc => $doc,
+  foundry => $token_base_foundry,
+  layer => $token_base_layer,
+  name => 'tokens'
+);
+ok($tokens, 'Token Object is fine');
+ok($tokens->parse, 'Token parsing is fine');
+
+my $output = decode_json( $tokens->to_json );
+
+is(substr($output->{data}->{text}, 0, 100), 'unser gemeinsames Werk wird siegreich sein Neujahrsbotschaft des Präsidenten der DeutschenDemokratis', 'Primary Data');
+is($output->{data}->{name}, 'tokens', 'tokenName');
+is($output->{data}->{tokenSource}, 'opennlp#tokens', 'tokenSource');
+is($output->{version}, '0.03', 'version');
+is($output->{data}->{foundries}, '', 'Foundries');
+is($output->{data}->{layerInfos}, '', 'layerInfos');
+is($output->{data}->{stream}->[0]->[3], 's:unser', 'data');
+
+is($output->{textSigle}, 'BZK_D59.00001', 'Correct text sigle');
+is($output->{docSigle}, 'BZK_D59', 'Correct document sigle');
+is($output->{corpusSigle}, 'BZK', 'Correct corpus sigle');
+
+is($output->{title}, 'Unser gemeinsames Werk wird siegreich sein', 'Title');
+ok(!exists $output->{subTitle}, 'No SubTitle');
+ok(!exists $output->{author}, 'Author');
+ok(!exists $output->{editor}, 'Publisher');
+
+is($output->{pubPlace}, 'Berlin', 'PubPlace');
+ok(!exists $output->{publisher}, 'Publisher');
+
+is($output->{textType}, 'Zeitung: Tageszeitung', 'Correct Text Type');
+ok(!exists $output->{textTypeArt}, 'Correct Text Type Art');
+is($output->{textTypeRef}, 'Tageszeitung', 'Correct Text Type Ref');
+is($output->{textDomain}, 'Politik', 'Correct Text Domain');
+
+is($output->{creationDate}, '19590101', 'Creation date');
+is($output->{license}, 'ACA-NC-LC', 'License');
+ok(!exists $output->{pages}, 'Pages');
+ok(!exists $output->{fileEditionStatement}, 'File Statement');
+ok(!exists $output->{biblEditionStatement}, 'Bibl Statement');
+
+is($output->{reference} . "\n", <<'REF', 'Reference');
+Neues Deutschland, [Tageszeitung], 01.01.1959, Jg. 14, Berliner Ausgabe, S. 1. - Sachgebiet: Politik, Originalressort: POLITIK; Unser gemeinsames Werk wird siegreich sein
+REF
+is($output->{language}, 'de', 'Language');
+
+is($output->{corpusTitle}, 'Bonner Zeitungskorpus', 'Correct Corpus title');
+ok(!exists $output->{corpusSubTitle}, 'Correct Corpus sub title');
+ok(!exists $output->{corpusAuthor}, 'Correct Corpus author');
+ok(!exists $output->{corpusEditor}, 'Correct Corpus editor');
+
+is($output->{docTitle}, 'Neues Deutschland', 'Correct Doc title');
+is($output->{docSubTitle}, 'Organ des Zentralkomitees der Sozialistischen Einheitspartei Deutschlands', 'Correct Doc sub title');
+ok(!exists $output->{docAuthor}, 'Correct Doc author');
+ok(!exists $output->{docEditor}, 'Correct doc editor');
+
+## Base
+$tokens->add('Base', 'Sentences');
+$tokens->add('Base', 'Paragraphs');
+
+$output = decode_json( $tokens->to_json );
+
+
+is($output->{data}->{foundries}, 'base base/paragraphs base/sentences', 'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans', 'layerInfos');
+my $first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr/s:unser/, 'data');
+like($first_token, qr/_0\$<i>0<i>5/, 'data');
+
+## OpenNLP
+$tokens->add('OpenNLP', 'Sentences');
+
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/s=spans', 'layerInfos');
+
+
+$tokens->add('OpenNLP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans', 'layerInfos');
+
+
+## Treetagger
+$tokens->add('TreeTagger', 'Sentences');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/s=spans', 'layerInfos');
+
+$tokens->add('TreeTagger', 'Morpho');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+
+## CoreNLP
+$tokens->add('CoreNLP', 'NamedEntities');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences corenlp corenlp/namedentities opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans corenlp/ne=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+
+$tokens->add('CoreNLP', 'Sentences');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences corenlp corenlp/namedentities corenlp/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans corenlp/ne=tokens corenlp/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+
+$tokens->add('CoreNLP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!corenlp/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!corenlp/p=tokens!, 'layerInfos');
+
+$tokens->add('CoreNLP', 'Constituency');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!corenlp/constituency!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!corenlp/c=spans!, 'layerInfos');
+
+## Glemm
+$tokens->add('Glemm', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!glemm/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!glemm/l=tokens!, 'layerInfos');
+
+## Connexor
+$tokens->add('Connexor', 'Sentences');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/sentences!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/s=spans!, 'layerInfos');
+
+$tokens->add('Connexor', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/p=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!cnx/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!cnx/m=tokens!, 'layerInfos');
+
+$tokens->add('Connexor', 'Phrase');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/phrase!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/c=spans!, 'layerInfos');
+
+$tokens->add('Connexor', 'Syntax');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/syntax!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/syn=tokens!, 'layerInfos');
+
+## Mate - not in existence
+{
+  local $SIG{__WARN__} = sub {};
+  $tokens->add('Mate', 'Morpho');
+  $output = decode_json( $tokens->to_json );
+  unlike($output->{data}->{foundries}, qr!mate/morpho!, 'Foundries');
+  unlike($output->{data}->{layerInfos}, qr!mate/p=tokens!, 'layerInfos');
+  unlike($output->{data}->{layerInfos}, qr!mate/l=tokens!, 'layerInfos');
+  unlike($output->{data}->{layerInfos}, qr!mate/m=tokens!, 'layerInfos');
+};
+
+# diag "No test for mate dependency";
+
+## XIP
+$tokens->add('XIP', 'Sentences');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/sentences!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/s=spans!, 'layerInfos');
+
+$tokens->add('XIP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!xip/p=tokens!, 'layerInfos');
+
+
+$tokens->add('XIP', 'Constituency');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/constituency!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/c=spans!, 'layerInfos');
+
+# diag "No test for xip dependency";
+
+
+done_testing;
+__END__
diff --git a/t/real/bzk_2.t b/t/real/bzk_2.t
new file mode 100644
index 0000000..62a1a34
--- /dev/null
+++ b/t/real/bzk_2.t
@@ -0,0 +1,261 @@
+use strict;
+use warnings;
+use Test::More;
+use Data::Dumper;
+use JSON::XS;
+
+use Benchmark qw/:hireswallclock/;
+
+my $t = Benchmark->new;
+
+use utf8;
+use lib 'lib', '../lib';
+
+use File::Basename 'dirname';
+use File::Spec::Functions 'catdir';
+
+use_ok('KorAP::Document');
+
+my $path = catdir(dirname(__FILE__), '../corpus/BZK/D59/00089');
+
+ok(my $doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document');
+ok($doc->parse, 'Parse document');
+
+is($doc->text_sigle, 'BZK_D59.00089', 'Correct text sigle');
+is($doc->doc_sigle, 'BZK_D59', 'Correct document sigle');
+is($doc->corpus_sigle, 'BZK', 'Correct corpus sigle');
+
+is($doc->title, 'Saragat-Partei zerfällt', 'Title');
+ok(!$doc->sub_title, 'No SubTitle');
+ok(!$doc->author, 'Author');
+ok(!$doc->editor, 'Editor');
+is($doc->pub_place, 'Berlin', 'PubPlace');
+is($doc->pub_date, '19590219', 'PubDate');
+ok(!$doc->publisher, 'Publisher');
+
+is($doc->text_type, 'Zeitung: Tageszeitung', 'Correct Text Type');
+
+ok(!$doc->text_type_art, 'Correct Text Type Art');
+is($doc->text_type_ref, 'Tageszeitung', 'Correct Text Type Ref');
+is($doc->text_domain, 'Politik', 'Correct Text Domain');
+is($doc->text_column, 'POLITIK', 'Correct Text Column');
+is($doc->text_class->[0], 'politik', 'Correct Text Class');
+is($doc->text_class->[1], 'ausland', 'Correct Text Class');
+ok(!$doc->text_class->[2], 'Correct Text Class');
+
+
+is($doc->creation_date, '19590219', 'Creation date');
+is($doc->license, 'ACA-NC-LC', 'License');
+ok(!$doc->pages, 'Pages');
+
+ok(!$doc->file_edition_statement, 'File Statement');
+ok(!$doc->bibl_edition_statement, 'Bibl Statement');
+
+is($doc->reference . "\n", <<'REF', 'Reference');
+Neues Deutschland, [Tageszeitung], 19.02.1959, Jg. 14, Berliner Ausgabe, S. 7. - Sachgebiet: Politik, Originalressort: POLITIK; Saragat-Partei zerfällt
+REF
+is($doc->language, 'de', 'Language');
+
+is($doc->corpus_title, 'Bonner Zeitungskorpus', 'Correct Corpus title');
+ok(!$doc->corpus_sub_title, 'Correct Corpus sub title');
+ok(!$doc->corpus_author, 'Correct Corpus author');
+ok(!$doc->corpus_editor, 'Correct Corpus editor');
+
+is($doc->doc_title, 'Neues Deutschland', 'Correct Doc title');
+is($doc->doc_sub_title, 'Organ des Zentralkomitees der Sozialistischen Einheitspartei Deutschlands', 'Correct Doc sub title');
+ok(!$doc->doc_author, 'Correct Doc author');
+ok(!$doc->doc_editor, 'Correct doc editor');
+
+# Tokenization
+use_ok('KorAP::Tokenizer');
+
+my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/);
+
+# Get tokenization
+my $tokens = KorAP::Tokenizer->new(
+  path => $doc->path,
+  doc => $doc,
+  foundry => $token_base_foundry,
+  layer => $token_base_layer,
+  name => 'tokens'
+);
+ok($tokens, 'Token Object is fine');
+ok($tokens->parse, 'Token parsing is fine');
+
+my $output = decode_json( $tokens->to_json );
+
+is(substr($output->{data}->{text}, 0, 100), 'Saragat-Partei zerfällt Rom (ADN) die von dem Rechtssozialisten Saragat geführte Sozialdemokratische', 'Primary Data');
+is($output->{data}->{name}, 'tokens', 'tokenName');
+is($output->{data}->{tokenSource}, 'opennlp#tokens', 'tokenSource');
+is($output->{version}, '0.03', 'version');
+is($output->{data}->{foundries}, '', 'Foundries');
+is($output->{data}->{layerInfos}, '', 'layerInfos');
+is($output->{data}->{stream}->[0]->[3], 's:Saragat-Partei', 'data');
+
+is($output->{textSigle}, 'BZK_D59.00089', 'Correct text sigle');
+is($output->{docSigle}, 'BZK_D59', 'Correct document sigle');
+is($output->{corpusSigle}, 'BZK', 'Correct corpus sigle');
+
+is($output->{title}, 'Saragat-Partei zerfällt', 'Title');
+ok(!exists $output->{subTitle}, 'No SubTitle');
+ok(!exists $output->{author}, 'Author');
+ok(!exists $output->{editor}, 'Publisher');
+
+is($output->{pubPlace}, 'Berlin', 'PubPlace');
+ok(!exists $output->{publisher}, 'Publisher');
+
+is($output->{textType}, 'Zeitung: Tageszeitung', 'Correct Text Type');
+ok(!exists $output->{textTypeArt}, 'Correct Text Type Art');
+is($output->{textTypeRef}, 'Tageszeitung', 'Correct Text Type Ref');
+is($output->{textDomain}, 'Politik', 'Correct Text Domain');
+is($output->{textClass}, 'politik ausland', 'Correct Text Domain');
+
+is($output->{creationDate}, '19590219', 'Creation date');
+is($output->{license}, 'ACA-NC-LC', 'License');
+ok(!exists $output->{pages}, 'Pages');
+ok(!exists $output->{fileEditionStatement}, 'File Statement');
+ok(!exists $output->{biblEditionStatement}, 'Bibl Statement');
+
+is($output->{reference} . "\n", <<'REF', 'Reference');
+Neues Deutschland, [Tageszeitung], 19.02.1959, Jg. 14, Berliner Ausgabe, S. 7. - Sachgebiet: Politik, Originalressort: POLITIK; Saragat-Partei zerfällt
+REF
+is($output->{language}, 'de', 'Language');
+
+is($output->{corpusTitle}, 'Bonner Zeitungskorpus', 'Correct Corpus title');
+ok(!exists $output->{corpusSubTitle}, 'Correct Corpus sub title');
+ok(!exists $output->{corpusAuthor}, 'Correct Corpus author');
+ok(!exists $output->{corpusEditor}, 'Correct Corpus editor');
+
+is($output->{docTitle}, 'Neues Deutschland', 'Correct Doc title');
+is($output->{docSubTitle}, 'Organ des Zentralkomitees der Sozialistischen Einheitspartei Deutschlands', 'Correct Doc sub title');
+ok(!exists $output->{docAuthor}, 'Correct Doc author');
+ok(!exists $output->{docEditor}, 'Correct doc editor');
+
+## Base
+$tokens->add('Base', 'Sentences');
+$tokens->add('Base', 'Paragraphs');
+
+$output = decode_json( $tokens->to_json );
+
+is($output->{data}->{foundries}, 'base base/paragraphs base/sentences', 'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans', 'layerInfos');
+my $first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr/s:Saragat-Partei/, 'data');
+like($first_token, qr/_0\$<i>0<i>14/, 'data');
+
+## OpenNLP
+$tokens->add('OpenNLP', 'Sentences');
+
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/s=spans', 'layerInfos');
+
+$tokens->add('OpenNLP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans', 'layerInfos');
+
+## Treetagger
+$tokens->add('TreeTagger', 'Sentences');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/s=spans', 'layerInfos');
+
+$tokens->add('TreeTagger', 'Morpho');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+
+## CoreNLP
+$tokens->add('CoreNLP', 'NamedEntities');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences corenlp corenlp/namedentities opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans corenlp/ne=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+
+$tokens->add('CoreNLP', 'Sentences');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences corenlp corenlp/namedentities corenlp/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans corenlp/ne=tokens corenlp/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+
+$tokens->add('CoreNLP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!corenlp/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!corenlp/p=tokens!, 'layerInfos');
+
+$tokens->add('CoreNLP', 'Constituency');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!corenlp/constituency!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!corenlp/c=spans!, 'layerInfos');
+
+## Glemm
+$tokens->add('Glemm', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!glemm/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!glemm/l=tokens!, 'layerInfos');
+
+## Connexor
+$tokens->add('Connexor', 'Sentences');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/sentences!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/s=spans!, 'layerInfos');
+
+$tokens->add('Connexor', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/p=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!cnx/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!cnx/m=tokens!, 'layerInfos');
+
+$tokens->add('Connexor', 'Phrase');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/phrase!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/c=spans!, 'layerInfos');
+
+$tokens->add('Connexor', 'Syntax');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/syntax!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/syn=tokens!, 'layerInfos');
+
+## Mate
+$tokens->add('Mate', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!mate/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!mate/p=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!mate/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!mate/m=tokens!, 'layerInfos');
+
+# diag "No test for mate dependency";
+
+## XIP
+$tokens->add('XIP', 'Sentences');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/sentences!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/s=spans!, 'layerInfos');
+
+$tokens->add('XIP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!xip/p=tokens!, 'layerInfos');
+
+$tokens->add('XIP', 'Constituency');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/constituency!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/c=spans!, 'layerInfos');
+
+# diag "No test for xip dependency";
+
+done_testing;
+__END__
diff --git a/t/real/goethe.t b/t/real/goethe.t
new file mode 100644
index 0000000..ae33e8d
--- /dev/null
+++ b/t/real/goethe.t
@@ -0,0 +1,322 @@
+use strict;
+use warnings;
+use Test::More;
+use Data::Dumper;
+use JSON::XS;
+
+use Benchmark qw/:hireswallclock/;
+
+my $t = Benchmark->new;
+
+use utf8;
+use lib 'lib', '../lib';
+
+use File::Basename 'dirname';
+use File::Spec::Functions 'catdir';
+
+use_ok('KorAP::Document');
+
+# GOE/AGA/03828
+my $path = catdir(dirname(__FILE__), '../corpus/GOE/AGA/03828');
+# my $path = '/home/ndiewald/Repositories/korap/KorAP-sandbox/KorAP-lucene-indexer/t/GOE/AGA/03828';
+
+ok(my $doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document');
+ok($doc->parse, 'Parse document');
+
+is($doc->text_sigle, 'GOE_AGA.03828', 'Correct text sigle');
+is($doc->doc_sigle, 'GOE_AGA', 'Correct document sigle');
+is($doc->corpus_sigle, 'GOE', 'Correct corpus sigle');
+
+is($doc->title, 'Autobiographische Einzelheiten', 'Title');
+is($doc->pub_place, 'München', 'PubPlace');
+is($doc->pub_date, '19820000', 'Creation Date');
+ok(!$doc->sub_title, 'SubTitle');
+is($doc->author, 'Goethe, Johann Wolfgang von', 'Author');
+
+is($doc->publisher, 'Verlag C. H. Beck', 'Publisher');
+ok(!$doc->editor, 'Publisher');
+is($doc->text_type, 'Autobiographie', 'Correct Text Type');
+ok(!$doc->text_type_art, 'Correct Text Type Art');
+ok(!$doc->text_type_ref, 'Correct Text Type Ref');
+ok(!$doc->text_column, 'Correct Text Column');
+ok(!$doc->text_domain, 'Correct Text Domain');
+is($doc->creation_date, '18200000', 'Creation Date');
+is($doc->license, 'QAO-NC', 'License');
+is($doc->pages, '529-547', 'Pages');
+ok(!$doc->file_edition_statement, 'File Ed Statement');
+ok(!$doc->bibl_edition_statement, 'Bibl Ed Statement');
+is($doc->reference . "\n", <<'REF', 'Author');
+Goethe, Johann Wolfgang von: Autobiographische Einzelheiten, (Geschrieben bis 1832), In: Goethe, Johann Wolfgang von: Goethes Werke, Bd. 10, Autobiographische Schriften II, Hrsg.: Trunz, Erich. München: Verlag C. H. Beck, 1982, S. 529-547
+REF
+is($doc->language, 'de', 'Language');
+
+
+is($doc->corpus_title, 'Goethes Werke', 'Correct Corpus title');
+ok(!$doc->corpus_sub_title, 'Correct Corpus Sub title');
+is($doc->corpus_author, 'Goethe, Johann Wolfgang von', 'Correct Corpus author');
+is($doc->corpus_editor, 'Trunz, Erich', 'Correct Corpus editor');
+
+is($doc->doc_title, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)',
+   'Correct Doc title');
+ok(!$doc->doc_sub_title, 'Correct Doc Sub title');
+ok(!$doc->doc_author, 'Correct Doc author');
+ok(!$doc->doc_editor, 'Correct Doc editor');
+
+# Tokenization
+use_ok('KorAP::Tokenizer');
+
+my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/);
+
+# Get tokenization
+my $tokens = KorAP::Tokenizer->new(
+  path => $doc->path,
+  doc => $doc,
+  foundry => $token_base_foundry,
+  layer => $token_base_layer,
+  name => 'tokens'
+);
+ok($tokens, 'Token Object is fine');
+ok($tokens->parse, 'Token parsing is fine');
+
+my $output = decode_json( $tokens->to_json );
+
+is(substr($output->{data}->{text}, 0, 100), 'Autobiographische einzelheiten Selbstschilderung (1) immer tätiger, nach innen und außen fortwirkend', 'Primary Data');
+is($output->{data}->{name}, 'tokens', 'tokenName');
+is($output->{data}->{tokenSource}, 'opennlp#tokens', 'tokenSource');
+is($output->{version}, '0.03', 'version');
+is($output->{data}->{foundries}, '', 'Foundries');
+is($output->{data}->{layerInfos}, '', 'layerInfos');
+is($output->{data}->{stream}->[0]->[3], 's:Autobiographische', 'data');
+
+is($output->{textSigle}, 'GOE_AGA.03828', 'Correct text sigle');
+is($output->{docSigle}, 'GOE_AGA', 'Correct document sigle');
+is($output->{corpusSigle}, 'GOE', 'Correct corpus sigle');
+
+is($output->{author}, 'Goethe, Johann Wolfgang von', 'Author');
+is($output->{pubPlace}, 'München', 'PubPlace');
+is($output->{pubDate}, '19820000', 'Creation Date');
+is($output->{title}, 'Autobiographische Einzelheiten', 'Title');
+ok(!exists $output->{subTitle}, 'subTitle');
+
+is($output->{publisher}, 'Verlag C. H. Beck', 'Publisher');
+ok(!exists $output->{editor}, 'Editor');
+is($output->{textType}, 'Autobiographie', 'Correct Text Type');
+ok(!exists $output->{textTypeArt}, 'Correct Text Type');
+ok(!exists $output->{textTypeRef}, 'Correct Text Type');
+ok(!exists $output->{textColumn}, 'Correct Text Type');
+ok(!exists $output->{textDomain}, 'Correct Text Type');
+is($output->{creationDate}, '18200000', 'Creation Date');
+is($output->{license}, 'QAO-NC', 'License');
+is($output->{pages}, '529-547', 'Pages');
+ok(!exists $output->{fileEditionStatement}, 'Correct Text Type');
+ok(!exists $output->{biblEditionStatement}, 'Correct Text Type');
+is($output->{reference} . "\n", <<'REF', 'Author');
+Goethe, Johann Wolfgang von: Autobiographische Einzelheiten, (Geschrieben bis 1832), In: Goethe, Johann Wolfgang von: Goethes Werke, Bd. 10, Autobiographische Schriften II, Hrsg.: Trunz, Erich. München: Verlag C. H. Beck, 1982, S. 529-547
+REF
+is($output->{language}, 'de', 'Language');
+
+is($output->{corpusTitle}, 'Goethes Werke', 'Correct Corpus title');
+ok(!exists $output->{corpusSubTitle}, 'Correct Text Type');
+is($output->{corpusAuthor}, 'Goethe, Johann Wolfgang von', 'Correct Corpus title');
+is($output->{corpusEditor}, 'Trunz, Erich', 'Editor');
+
+is($output->{docTitle}, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)', 'Correct Corpus title');
+ok(!exists $output->{docSubTitle}, 'Correct Text Type');
+ok(!exists $output->{docAuthor}, 'Correct Text Type');
+ok(!exists $output->{docEditor}, 'Correct Text Type');
+
+## Base
+$tokens->add('Base', 'Sentences');
+$tokens->add('Base', 'Paragraphs');
+
+$output = decode_json( $tokens->to_json );
+
+is($output->{data}->{foundries}, 'base base/paragraphs base/sentences', 'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans', 'layerInfos');
+my $first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr/s:Autobiographische/, 'data');
+like($first_token, qr/_0\$<i>0<i>17/, 'data');
+like($first_token, qr!<>:base/s:s\$<b>64<i>0<i>30<i>2<b>2!, 'data');
+like($first_token, qr!<>:base\/s:t\$<b>64<i>0<i>35199<i>5226<b>0!, 'data');
+
+## OpenNLP
+$tokens->add('OpenNLP', 'Sentences');
+
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/s=spans', 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!<>:opennlp/s:s\$<b>64<i>0<i>254<i>32!, 'data');
+
+$tokens->add('OpenNLP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans', 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!opennlp/p:ADJA!, 'data');
+
+## Treetagger
+$tokens->add('TreeTagger', 'Sentences');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/s=spans', 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!<>:tt/s:s\$<b>64<i>0<i>179<i>21<b>0!, 'data');
+
+$tokens->add('TreeTagger', 'Morpho');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!tt/l:autobiographisch\$<b>129<b>165!, 'data');
+like($first_token, qr!tt/p:ADJA\$<b>129<b>165!, 'data');
+like($first_token, qr!tt/l:Autobiographische\$<b>129<b>89!, 'data');
+like($first_token, qr!tt/p:NN\$<b>129<b>89!, 'data');
+
+## CoreNLP
+$tokens->add('CoreNLP', 'NamedEntities');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences corenlp corenlp/namedentities opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans corenlp/ne=tokens opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+
+# diag "Missing test for NamedEntities";
+
+# Problematic:
+# diag Dumper $output->{data}->{stream}->[180];
+# diag Dumper $output->{data}->{stream}->[341];
+
+$tokens->add('CoreNLP', 'Sentences');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences corenlp corenlp/namedentities corenlp/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans corenlp/ne=tokens corenlp/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!<>:corenlp/s:s\$<b>64<i>0<i>254<i>32<b>0!, 'data');
+
+$tokens->add('CoreNLP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!corenlp/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!corenlp/p=tokens!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!corenlp/p:ADJA!, 'data');
+
+$tokens->add('CoreNLP', 'Constituency');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!corenlp/constituency!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!corenlp/c=spans!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!<>:corenlp/c:NP\$<b>64<i>0<i>17<i>1<b>6!, 'data');
+like($first_token, qr!<>:corenlp/c:CNP\$<b>64<i>0<i>17<i>1<b>7!, 'data');
+like($first_token, qr!<>:corenlp/c:NP\$<b>64<i>0<i>17<i>1<b>8!, 'data');
+like($first_token, qr!<>:corenlp/c:AP\$<b>64<i>0<i>17<i>1<b>9!, 'data');
+like($first_token, qr!<>:corenlp/c:PP\$<b>64<i>0<i>50<i>3<b>4!, 'data');
+like($first_token, qr!<>:corenlp/c:S\$<b>64<i>0<i>50<i>3<b>5!, 'data');
+like($first_token, qr!<>:corenlp/c:PP\$<b>64<i>0<i>58<i>5<b>2!, 'data');
+like($first_token, qr!<>:corenlp/c:S\$<b>64<i>0<i>58<i>5<b>3!, 'data');
+like($first_token, qr!<>:corenlp/c:ROOT\$<b>64<i>0<i>254<i>32<b>0!, 'data');
+like($first_token, qr!<>:corenlp/c:S\$<b>64<i>0<i>254<i>32<b>1!, 'data');
+
+## Glemm
+$tokens->add('Glemm', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!glemm/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!glemm/l=tokens!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!glemm/l:__autobiographisch!, 'data');
+like($first_token, qr!glemm/l:\+_Auto!, 'data');
+like($first_token, qr!glemm/l:\+_biographisch!, 'data');
+like($first_token, qr!glemm/l:\+\+Biograph!, 'data');
+like($first_token, qr!glemm/l:\+\+-isch!, 'data');
+
+## Connexor
+$tokens->add('Connexor', 'Sentences');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/sentences!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/s=spans!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!<>:cnx/s:s\$<b>64<i>0<i>179<i>21<b>0!, 'data');
+
+$tokens->add('Connexor', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/p=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!cnx/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!cnx/m=tokens!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!cnx/l:autobiografisch!, 'data');
+like($first_token, qr!cnx/p:A!, 'data');
+
+$tokens->add('Connexor', 'Phrase');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/phrase!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/c=spans!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!<>:cnx/c:np\$<b>64<i>0<i>30<i>2!, 'data');
+
+$tokens->add('Connexor', 'Syntax');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/syntax!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/syn=tokens!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!cnx/syn:\@PREMOD!, 'data');
+
+## Mate
+$tokens->add('Mate', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!mate/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!mate/p=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!mate/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!mate/m=tokens!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!mate/l:autobiographisch!, 'data');
+like($first_token, qr!mate/p:NN!, 'data');
+like($first_token, qr!mate/m:case:nom!, 'data');
+like($first_token, qr!mate/m:number:pl!, 'data');
+like($first_token, qr!mate/m:gender:\*!, 'data');
+
+# diag "No test for mate dependency";
+
+## XIP
+$tokens->add('XIP', 'Sentences');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/sentences!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/s=spans!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!<>:xip/s:s\$<b>64<i>0<i>179<i>21!, 'data');
+
+$tokens->add('XIP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!xip/p=tokens!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!<>:xip/s:s\$<b>64<i>0<i>179<i>21!, 'data');
+
+$tokens->add('XIP', 'Constituency');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/constituency!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/c=spans!, 'layerInfos');
+$first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr!<>:xip/c:NP\$<b>64<i>0<i>17<i>1<b>1!, 'data');
+like($first_token, qr!<>:xip/c:AP\$<b>64<i>0<i>17<i>1<b>2!, 'data');
+like($first_token, qr!<>:xip/c:ADJ\$<b>64<i>0<i>17<i>1<b>3!, 'data');
+like($first_token, qr!<>:xip/c:TOP\$<b>64<i>0<i>179<i>21<b>0!, 'data');
+
+# diag "No test for xip dependency";
+
+# print timestr(timediff(Benchmark->new, $t));
+
+done_testing;
+__END__
diff --git a/t/real/real_goethe_benchmark.t b/t/real/real_goethe_benchmark.t
new file mode 100644
index 0000000..68e486a
--- /dev/null
+++ b/t/real/real_goethe_benchmark.t
@@ -0,0 +1,98 @@
+#!/usr/bin/env perl
+# source ~/perl5/perlbrew/etc/bashrc
+# perlbrew switch perl-blead@korap
+use strict;
+use warnings;
+use Mojo::ByteStream 'b';
+use Devel::Cycle;
+use Memory::Stats;
+
+use Benchmark qw/:hireswallclock/;
+
+my $t = Benchmark->new;
+
+use utf8;
+use lib 'lib', '../lib';
+
+use File::Basename 'dirname';
+use File::Spec::Functions 'catdir';
+
+# Tokenization
+use KorAP::Tokenizer;
+use KorAP::Document;
+
+# my $stats = Memory::Stats->new;
+
+#$stats->start;
+
+# GOE/AGA/03828
+#my $path = catdir(dirname(__FILE__), 'GOE/AGA/03828');
+my $path = catdir(dirname(__FILE__), 'BZK/D59/00089');
+# Todo: Test with absolute path!
+
+# do something
+#$stats->checkpoint(sprintf("%20s", "Init"));
+
+my $doc = KorAP::Document->new( path => $path . '/' );
+$doc->parse;
+# $stats->checkpoint(sprintf("%20s", "After Parsing"));
+
+my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/);
+
+# Get tokenization
+my $tokens = KorAP::Tokenizer->new(
+  path => $doc->path,
+  doc => $doc,
+  foundry => $token_base_foundry,
+  layer => $token_base_layer,
+  name => 'tokens'
+);
+$tokens->parse;
+#$stats->checkpoint(sprintf("%20s", "After Tokenization"));
+
+$tokens->add('Base', 'Sentences');
+#$stats->checkpoint(sprintf("%20s", "After Base/Sentences"));
+
+$tokens->add('Base', 'Paragraphs');
+#$stats->checkpoint(sprintf("%20s", "After Base/Paragraphs"));
+
+$tokens->add('OpenNLP', 'Sentences');
+#$stats->checkpoint(sprintf("%20s", "After OpenNLP/Sentences"));
+
+$tokens->add('OpenNLP', 'Morpho');
+#$stats->checkpoint(sprintf("%20s", "After OpenNLP/Morpho"));
+
+$tokens->add('TreeTagger', 'Sentences');
+#$stats->checkpoint(sprintf("%20s", "After TT/Sentences"));
+
+$tokens->add('TreeTagger', 'Morpho');
+#$stats->checkpoint(sprintf("%20s", "After TT/Morpho"));
+
+$tokens->add('CoreNLP', 'Sentences');
+#$stats->checkpoint(sprintf("%20s", "After CoreNLP/Sentences"));
+
+$tokens->add('CoreNLP', 'Constituency');
+#$stats->checkpoint(sprintf("%20s", "After CoreNLP/Constituency"));
+
+#$stats->stop;
+#$stats->report;
+
+$tokens->add('CoreNLP', 'NamedEntities');
+$tokens->add('CoreNLP', 'Morpho');
+$tokens->add('Glemm', 'Morpho');
+# t ok($tokens->add('Connexor', 'Sentences'),    'Add cnx sentences');
+# t ok($tokens->add('Connexor', 'Morpho'),       'Add cnx morpho');
+# t ok($tokens->add('Connexor', 'Phrase'),       'Add cnx phrase');
+# t ok($tokens->add('Connexor', 'Syntax'),       'Add cnx syntax');
+$tokens->add('Mate', 'Morpho');
+# $tokens->add('Mate', 'Dependency');
+# t ok($tokens->add('XIP', 'Sentences'),         'Add xip sentences');
+# t ok($tokens->add('XIP', 'Morpho'),            'Add xip morpho');
+# t ok($tokens->add('XIP', 'Constituency'),      'Add xip constituency');
+# $tokens->add('XIP', 'Dependency');
+# ok($tokens->to_json, 'To json');
+
+#b($tokens->to_json)->spurt('AGA-03828.json');
+b($tokens->to_json)->spurt('D59-00089.json');
+
+# timestr(timediff(Benchmark->new, $t));
diff --git a/t/real/wdd.t b/t/real/wdd.t
new file mode 100644
index 0000000..4ed33d5
--- /dev/null
+++ b/t/real/wdd.t
@@ -0,0 +1,271 @@
+#!/usr/bin/env perl
+# source ~/perl5/perlbrew/etc/bashrc
+# perlbrew switch perl-blead@korap
+use strict;
+use warnings;
+use Test::More;
+use Data::Dumper;
+use JSON::XS;
+
+use Benchmark qw/:hireswallclock/;
+
+my $t = Benchmark->new;
+
+use utf8;
+use lib 'lib', '../lib';
+
+use File::Basename 'dirname';
+use File::Spec::Functions 'catdir';
+
+use_ok('KorAP::Document');
+
+# GOE/AGA/03828
+my $path = catdir(dirname(__FILE__), '../corpus/WDD/G27/38989');
+
+ok(my $doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document');
+ok($doc->parse, 'Parse document');
+
+is($doc->text_sigle, 'WDD11_G27.38989', 'Correct text sigle');
+is($doc->doc_sigle, 'WDD11_G27', 'Correct document sigle');
+is($doc->corpus_sigle, 'WDD11', 'Correct corpus sigle');
+
+is($doc->title, 'Diskussion:Gunter A. Pilz', 'Title');
+ok(!$doc->sub_title, 'No SubTitle');
+is($doc->author, '€pa, u.a.', 'Author');
+ok(!$doc->editor, 'Publisher');
+
+is($doc->pub_place, 'URL:http://de.wikipedia.org', 'PubPlace');
+is($doc->publisher, 'Wikipedia', 'Publisher');
+is($doc->text_type, 'Diskussionen zu Enzyklopädie-Artikeln', 'Correct Text Type');
+ok(!$doc->text_type_art, 'Correct Text Type Art');
+ok(!$doc->text_type_ref, 'Correct Text Type Ref');
+ok(!$doc->text_domain, 'Correct Text Domain');
+is($doc->creation_date, '20070707', 'Creation date');
+is($doc->license, 'CC-BY-SA', 'License');
+ok(!$doc->pages, 'Pages');
+ok(!$doc->file_edition_statement, 'File Statement');
+ok(!$doc->bibl_edition_statement, 'Bibl Statement');
+is($doc->reference . "\n", <<'REF', 'Reference');
+Diskussion:Gunter A. Pilz, In: Wikipedia - URL:http://de.wikipedia.org/wiki/Diskussion:Gunter_A._Pilz: Wikipedia, 2007
+REF
+is($doc->language, 'de', 'Language');
+
+is($doc->corpus_title, 'Wikipedia', 'Correct Corpus title');
+ok(!$doc->corpus_sub_title, 'Correct Corpus sub title');
+ok(!$doc->corpus_author, 'Correct Corpus author');
+is($doc->corpus_editor, 'wikipedia.org', 'Correct Corpus editor');
+
+is($doc->doc_title, 'Wikipedia, Diskussionen zu Artikeln mit Anfangsbuchstabe G, Teil 27', 'Correct Doc title');
+ok(!$doc->doc_sub_title, 'Correct Doc sub title');
+ok(!$doc->doc_author, 'Correct Doc author');
+ok(!$doc->doc_editor, 'Correct doc editor');
+
+# Tokenization
+use_ok('KorAP::Tokenizer');
+
+my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/);
+
+# Get tokenization
+my $tokens = KorAP::Tokenizer->new(
+  path => $doc->path,
+  doc => $doc,
+  foundry => $token_base_foundry,
+  layer => $token_base_layer,
+  name => 'tokens'
+);
+ok($tokens, 'Token Object is fine');
+ok($tokens->parse, 'Token parsing is fine');
+
+my $output = decode_json( $tokens->to_json );
+
+is(substr($output->{data}->{text}, 0, 100), '{{War Löschkandidat|6. Juli 2007|(erl., bleibt)}}', 'Primary Data');
+is($output->{data}->{name}, 'tokens', 'tokenName');
+is($output->{data}->{tokenSource}, 'opennlp#tokens', 'tokenSource');
+is($output->{version}, '0.03', 'version');
+is($output->{data}->{foundries}, '', 'Foundries');
+is($output->{data}->{layerInfos}, '', 'layerInfos');
+is($output->{data}->{stream}->[0]->[3], 's:{War', 'data');
+
+is($output->{textSigle}, 'WDD11_G27.38989', 'Correct text sigle');
+is($output->{docSigle}, 'WDD11_G27', 'Correct document sigle');
+is($output->{corpusSigle}, 'WDD11', 'Correct corpus sigle');
+
+is($output->{title}, 'Diskussion:Gunter A. Pilz', 'Title');
+ok(!$output->{subTitle}, 'No SubTitle');
+is($output->{author}, '€pa, u.a.', 'Author');
+ok(!$output->{editor}, 'Editor');
+
+is($output->{pubPlace}, 'URL:http://de.wikipedia.org', 'PubPlace');
+is($output->{publisher}, 'Wikipedia', 'Publisher');
+is($output->{textType}, 'Diskussionen zu Enzyklopädie-Artikeln', 'Correct Text Type');
+ok(!$output->{textTypeArt}, 'Correct Text Type Art');
+ok(!$output->{textTypeRef}, 'Correct Text Type Ref');
+ok(!$output->{textDomain}, 'Correct Text Domain');
+is($output->{creationDate}, '20070707', 'Creation date');
+is($output->{license}, 'CC-BY-SA', 'License');
+ok(!$output->{pages}, 'Pages');
+ok(!$output->{fileEditionStatement}, 'File Statement');
+ok(!$output->{biblEditionStatement}, 'Bibl Statement');
+is($output->{reference} . "\n", <<'REF', 'Reference');
+Diskussion:Gunter A. Pilz, In: Wikipedia - URL:http://de.wikipedia.org/wiki/Diskussion:Gunter_A._Pilz: Wikipedia, 2007
+REF
+is($output->{language}, 'de', 'Language');
+
+is($output->{corpusTitle}, 'Wikipedia', 'Correct Corpus title');
+ok(!$output->{corpusSubTitle}, 'Correct Corpus sub title');
+ok(!$output->{corpusAuthor}, 'Correct Corpus author');
+is($output->{corpusEditor}, 'wikipedia.org', 'Correct Corpus editor');
+
+is($output->{docTitle}, 'Wikipedia, Diskussionen zu Artikeln mit Anfangsbuchstabe G, Teil 27', 'Correct Doc title');
+ok(!$output->{docSubTitle}, 'Correct Doc sub title');
+ok(!$output->{docAuthor}, 'Correct Doc author');
+ok(!$output->{docEditor}, 'Correct doc editor');
+
+## Base
+$tokens->add('Base', 'Sentences');
+
+$tokens->add('Base', 'Paragraphs');
+
+$output = decode_json( $tokens->to_json );
+
+is($output->{data}->{foundries}, 'base base/paragraphs base/sentences', 'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans', 'layerInfos');
+my $first_token = join('||', @{$output->{data}->{stream}->[0]});
+like($first_token, qr/s:{War/, 'data');
+like($first_token, qr/_0\$<i>1<i>5/, 'data');
+
+
+## OpenNLP
+$tokens->add('OpenNLP', 'Sentences');
+
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/s=spans', 'layerInfos');
+
+
+$tokens->add('OpenNLP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans', 'layerInfos');
+
+
+## Treetagger
+$tokens->add('TreeTagger', 'Sentences');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/s=spans', 'layerInfos');
+
+$tokens->add('TreeTagger', 'Morpho');
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+
+## CoreNLP
+{
+  local $SIG{__WARN__} = sub {};
+  $tokens->add('CoreNLP', 'NamedEntities');
+};
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+
+
+{
+  local $SIG{__WARN__} = sub {};
+  $tokens->add('CoreNLP', 'Sentences');
+};
+$output = decode_json( $tokens->to_json );
+is($output->{data}->{foundries},
+   'base base/paragraphs base/sentences opennlp opennlp/morpho opennlp/sentences treetagger treetagger/morpho treetagger/sentences',
+   'Foundries');
+is($output->{data}->{layerInfos}, 'base/s=spans opennlp/p=tokens opennlp/s=spans tt/l=tokens tt/p=tokens tt/s=spans', 'layerInfos');
+
+{
+  local $SIG{__WARN__} = sub {};
+  $tokens->add('CoreNLP', 'Morpho');
+};
+$output = decode_json( $tokens->to_json );
+unlike($output->{data}->{foundries}, qr!corenlp/morpho!, 'Foundries');
+unlike($output->{data}->{layerInfos}, qr!corenlp/p=tokens!, 'layerInfos');
+
+{
+  local $SIG{__WARN__} = sub {};
+  $tokens->add('CoreNLP', 'Constituency');
+};
+$output = decode_json( $tokens->to_json );
+unlike($output->{data}->{foundries}, qr!corenlp/constituency!, 'Foundries');
+unlike($output->{data}->{layerInfos}, qr!corenlp/c=spans!, 'layerInfos');
+
+## Glemm
+{
+  local $SIG{__WARN__} = sub {};
+  $tokens->add('Glemm', 'Morpho');
+};
+$output = decode_json( $tokens->to_json );
+unlike($output->{data}->{foundries}, qr!glemm/morpho!, 'Foundries');
+unlike($output->{data}->{layerInfos}, qr!glemm/l=tokens!, 'layerInfos');
+
+## Connexor
+$tokens->add('Connexor', 'Sentences');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/sentences!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/s=spans!, 'layerInfos');
+
+$tokens->add('Connexor', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/p=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!cnx/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!cnx/m=tokens!, 'layerInfos');
+
+$tokens->add('Connexor', 'Phrase');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/phrase!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/c=spans!, 'layerInfos');
+
+$tokens->add('Connexor', 'Syntax');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!connexor/syntax!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!cnx/syn=tokens!, 'layerInfos');
+
+## Mate
+$tokens->add('Mate', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!mate/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!mate/p=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!mate/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!mate/m=tokens!, 'layerInfos');
+
+# diag "No test for mate dependency";
+
+## XIP
+$tokens->add('XIP', 'Sentences');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/sentences!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/s=spans!, 'layerInfos');
+
+$tokens->add('XIP', 'Morpho');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/morpho!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/l=tokens!, 'layerInfos');
+like($output->{data}->{layerInfos}, qr!xip/p=tokens!, 'layerInfos');
+
+$tokens->add('XIP', 'Constituency');
+$output = decode_json( $tokens->to_json );
+like($output->{data}->{foundries}, qr!xip/constituency!, 'Foundries');
+like($output->{data}->{layerInfos}, qr!xip/c=spans!, 'layerInfos');
+
+# diag "No test for xip dependency";
+
+done_testing;
+__END__