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; |
| 11 | my $path = catdir(dirname(__FILE__), 'corpus', 'doc', $file); |
| 12 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 13 | my $doc = KorAP::XML::Krill->new( |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 14 | path => $path . '/' |
| 15 | ) or return; |
| 16 | |
| 17 | $doc->parse; |
| 18 | |
Akron | e4c2e41 | 2016-01-28 15:10:50 +0100 | [diff] [blame] | 19 | my $tokens = KorAP::XML::Tokenizer->new( |
Akron | ef8544f | 2016-01-16 14:51:07 +0100 | [diff] [blame] | 20 | path => $doc->path, |
| 21 | doc => $doc, |
| 22 | foundry => 'OpenNLP', |
| 23 | layer => 'Tokens', |
| 24 | name => 'tokens' |
| 25 | ) or return; |
| 26 | |
| 27 | $tokens->parse or return; |
| 28 | |
| 29 | return $tokens; |
| 30 | }; |
| 31 | |
| 32 | 1; |