Akron | c388150 | 2017-01-20 14:36:37 +0100 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use Test::More; |
| 4 | use Data::Dumper; |
| 5 | use JSON::XS; |
| 6 | |
| 7 | use Benchmark qw/:hireswallclock/; |
| 8 | |
| 9 | my $t = Benchmark->new; |
| 10 | |
| 11 | use utf8; |
| 12 | use lib 'lib', '../lib'; |
| 13 | |
| 14 | use File::Basename 'dirname'; |
| 15 | use File::Spec::Functions 'catdir'; |
| 16 | |
| 17 | use_ok('KorAP::XML::Krill'); |
| 18 | |
| 19 | # This will Check DRuKoLa-Files |
| 20 | |
| 21 | # New |
| 22 | # BBU/BLOG/83709_a_82384 |
Akron | 3887301 | 2017-02-06 20:27:37 +0100 | [diff] [blame^] | 23 | my $path = catdir(dirname(__FILE__), '../corpus/CoRoLa/BBU/BLOG/83709_a_82384'); |
Akron | c388150 | 2017-01-20 14:36:37 +0100 | [diff] [blame] | 24 | |
| 25 | ok(my $doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 26 | ok($doc->parse, 'Parse document'); |
| 27 | |
| 28 | is($doc->text_sigle, 'BBU/BLOG/83709_a_82384', 'Correct text sigle'); |
| 29 | is($doc->doc_sigle, 'BBU/BLOG', 'Correct document sigle'); |
| 30 | is($doc->corpus_sigle, 'BBU', 'Correct corpus sigle'); |
| 31 | |
| 32 | my $meta = $doc->meta; |
| 33 | is($meta->{title}, 'Schimbă vorba', 'Title'); |
| 34 | is($meta->{pub_place}, 'URL:http://www.bucurenci.ro', 'PubPlace'); |
| 35 | is($meta->{pub_date}, '20131005', 'Creation Date'); |
| 36 | ok(!$meta->{sub_title}, 'SubTitle'); |
| 37 | is($meta->{author}, 'Dragoș Bucurenci', 'Author'); |
| 38 | |
| 39 | ok(!$meta->{publisher}, 'Publisher'); |
| 40 | ok(!$meta->{editor}, 'Editor'); |
Akron | 578af4b | 2017-01-20 16:28:50 +0100 | [diff] [blame] | 41 | is($meta->{translator}, '[TRANSLATOR]', 'Translator'); |
Akron | c388150 | 2017-01-20 14:36:37 +0100 | [diff] [blame] | 42 | #is($meta->{text_type}, 'Autobiographie', 'Correct Text Type'); |
| 43 | ok(!$meta->{text_type_art}, 'Correct Text Type Art'); |
| 44 | # is($meta->{text_type_ref}, '', 'Correct Text Type Ref'); |
| 45 | ok(!$meta->{text_column}, 'Correct Text Column'); |
| 46 | ok(!$meta->{text_domain}, 'Correct Text Domain'); |
| 47 | ok(!$meta->{creation_date}, 'Creation Date'); |
| 48 | |
| 49 | ok(!$meta->{pages}, 'Pages'); |
| 50 | ok(!$meta->{file_edition_statement}, 'File Ed Statement'); |
| 51 | ok(!$meta->{bibl_edition_statement}, 'Bibl Ed Statement'); |
| 52 | ok(!$meta->{reference}, 'Reference'); |
| 53 | is($meta->{language}, 'ro', 'Language'); |
| 54 | |
| 55 | #is($meta->{corpus_title}, 'Goethes Werke', 'Correct Corpus title'); |
| 56 | ok(!$meta->{corpus_sub_title}, 'Correct Corpus Sub title'); |
| 57 | #is($meta->{corpus_author}, 'Goethe, Johann Wolfgang von', 'Correct Corpus author'); |
| 58 | #is($meta->{corpus_editor}, 'Trunz, Erich', 'Correct Corpus editor'); |
| 59 | |
| 60 | #is($meta->{doc_title}, 'Goethe: Autobiographische Schriften II, (1817-1825, 1832)', |
| 61 | # 'Correct Doc title'); |
| 62 | ok(!$meta->{doc_sub_title}, 'Correct Doc Sub title'); |
| 63 | ok(!$meta->{doc_author}, 'Correct Doc author'); |
| 64 | ok(!$meta->{doc_editor}, 'Correct Doc editor'); |
| 65 | |
| 66 | # Tokenization |
| 67 | use_ok('KorAP::XML::Tokenizer'); |
| 68 | |
| 69 | my ($token_base_foundry, $token_base_layer) = (qw/Base Tokens_conservative/); |
| 70 | |
| 71 | # Get tokenization |
| 72 | my $tokens = KorAP::XML::Tokenizer->new( |
| 73 | path => $doc->path, |
| 74 | doc => $doc, |
| 75 | foundry => $token_base_foundry, |
| 76 | layer => $token_base_layer, |
| 77 | name => 'tokens' |
| 78 | ); |
| 79 | ok($tokens, 'Token Object is fine'); |
| 80 | ok($tokens->parse, 'Token parsing is fine'); |
| 81 | |
| 82 | my $output = decode_json( $tokens->to_json ); |
| 83 | |
| 84 | ## Base |
| 85 | $tokens->add('DeReKo', 'Structure', 'base_sentences_paragraphs'); |
| 86 | ok($tokens->add('DRuKoLa', 'Morpho'), 'Add Drukola'); |
| 87 | |
| 88 | $output = $tokens->to_data; |
| 89 | |
| 90 | is($output->{data}->{foundries}, 'dereko dereko/structure dereko/structure/base_sentences_paragraphs drukola drukola/morpho', 'Foundries'); |
| 91 | |
| 92 | is($output->{data}->{layerInfos}, 'dereko/s=spans drukola/l=tokens drukola/m=tokens drukola/p=tokens', 'layerInfos'); |
| 93 | |
| 94 | my $token = join('||', @{$output->{data}->{stream}->[7]}); |
| 95 | |
| 96 | like($token, qr!drukola/l:la!, 'data'); |
| 97 | like($token, qr!drukola/m:msd:Sp!, 'data'); |
| 98 | like($token, qr!drukola/p:ADPOSITION!, 'data'); |
| 99 | |
| 100 | $token = join('||', @{$output->{data}->{stream}->[9]}); |
| 101 | |
| 102 | like($token, qr!i:vorba!, 'data'); |
| 103 | like($token, qr!drukola/l:vorbă!, 'data'); |
| 104 | like($token, qr!drukola/m:case:Ncfsry!, 'data'); |
| 105 | like($token, qr!drukola/m:definiteness:yes!, 'data'); |
| 106 | like($token, qr!drukola/m:gender:feminine!, 'data'); |
| 107 | like($token, qr!drukola/p:NOUN!, 'data'); |
| 108 | |
Akron | a7d0e9f | 2017-02-03 14:36:21 +0100 | [diff] [blame] | 109 | |
| 110 | # New |
| 111 | # BBU2/BLOG/83709_a_82384 |
Akron | 3887301 | 2017-02-06 20:27:37 +0100 | [diff] [blame^] | 112 | $path = catdir(dirname(__FILE__), '../corpus/CoRoLa/BBU2/Blog/83701_a_82376'); |
Akron | a7d0e9f | 2017-02-03 14:36:21 +0100 | [diff] [blame] | 113 | |
| 114 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 115 | ok($doc->parse, 'Parse document'); |
| 116 | |
| 117 | $meta = $doc->meta; |
| 118 | |
| 119 | ok(!exists $meta->{doc_title}, 'No doc title'); |
| 120 | ok(!exists $meta->{translator}, 'No translator'); |
| 121 | |
| 122 | ok(!exists $meta->{text_class}, 'No translator'); |
| 123 | |
| 124 | |
Akron | 3887301 | 2017-02-06 20:27:37 +0100 | [diff] [blame^] | 125 | |
| 126 | $path = catdir(dirname(__FILE__), '../corpus/CoRoLa/Corola-Journal/-/247_a_537'); |
| 127 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 128 | ok($doc->parse, 'Parse document'); |
| 129 | |
| 130 | $meta = $doc->meta; |
| 131 | is($meta->text_sigle, 'Corola-Journal/-/247_a_537', 'Text Sigle'); |
| 132 | is($meta->doc_sigle, 'Corola-Journal/-', 'Doc Sigle'); |
| 133 | is($meta->corpus_sigle, 'Corola-Journal', 'Corpus Sigle'); |
| 134 | is($meta->{text_class}->[0], 'Sport', 'Text class'); |
| 135 | |
| 136 | |
| 137 | $path = catdir(dirname(__FILE__), '../corpus/CoRoLa/Corola-Journal/COLEGIUL NATIONAL „OCTAV BANCILA“ - IASI/326_a_562'); |
| 138 | ok($doc = KorAP::XML::Krill->new( path => $path . '/' ), 'Load Korap::Document'); |
| 139 | ok($doc->parse, 'Parse document'); |
| 140 | |
| 141 | $meta = $doc->meta; |
| 142 | is($meta->text_sigle, 'Corola-Journal/COLEGIUL NATIONAL „OCTAV BANCILA“ - IASI/326_a_562', 'Text Sigle'); |
| 143 | is($meta->doc_sigle, 'Corola-Journal/COLEGIUL NATIONAL „OCTAV BANCILA“ - IASI', 'Doc Sigle'); |
| 144 | is($meta->corpus_sigle, 'Corola-Journal', 'Corpus Sigle'); |
| 145 | is($meta->{title}, 'APOGEUL ARHITECTURĂ ȘI DESIGN', 'Title'); |
| 146 | |
Akron | c388150 | 2017-01-20 14:36:37 +0100 | [diff] [blame] | 147 | done_testing; |
| 148 | __END__ |