Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 1 | package TestInit; |
| 2 | use strict; |
| 3 | use warnings; |
| 4 | use File::Basename 'dirname'; |
| 5 | use File::Spec::Functions 'catdir'; |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 6 | use KorAP::XML::Tokenizer; |
| 7 | use KorAP::XML::Krill; |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 8 | |
| 9 | sub tokens { |
| 10 | my $file = shift; |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame^] | 11 | my $token_foundry = shift; |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 12 | my $path = catdir(dirname(__FILE__), 'corpus', 'doc', $file); |
| 13 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 14 | my $doc = KorAP::XML::Krill->new( |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 15 | path => $path . '/' |
| 16 | ) or return; |
| 17 | |
| 18 | $doc->parse; |
| 19 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 20 | my $tokens = KorAP::XML::Tokenizer->new( |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 21 | path => $doc->path, |
| 22 | doc => $doc, |
Akron | f3f0c94 | 2016-06-27 13:27:14 +0200 | [diff] [blame^] | 23 | foundry => ($token_foundry // 'OpenNLP'), |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 24 | layer => 'Tokens', |
| 25 | name => 'tokens' |
| 26 | ) or return; |
| 27 | |
| 28 | $tokens->parse or return; |
| 29 | |
| 30 | return $tokens; |
| 31 | }; |
| 32 | |
| 33 | 1; |