blob: 7a3010310b092ae0b3119fcf9287f6999509eed0 [file] [log] [blame]
Nils Diewaldf03c6802014-07-21 16:39:44 +00001#!/usr/bin/env perl
2# source ~/perl5/perlbrew/etc/bashrc
3# perlbrew switch perl-blead@korap
4use strict;
5use warnings;
6use utf8;
7use Test::More;
8use Benchmark ':hireswallclock';
9use lib 'lib', '../lib';
10use Scalar::Util qw/weaken/;
11
12use File::Basename 'dirname';
13use File::Spec::Functions 'catdir';
14
15use_ok('KorAP::Document');
16
17my $path = catdir(dirname(__FILE__), 'artificial');
18ok(my $doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document');
Nils Diewald19205712015-06-18 20:06:45 +000019like($doc->path, qr!$path/$!, 'Path');
Nils Diewaldf03c6802014-07-21 16:39:44 +000020ok($doc->parse, 'Parse document');
21
22sub new_tokenizer {
23 my $x = $doc;
24 weaken $x;
25 return KorAP::Tokenizer->new(
26 path => $x->path,
27 doc => $x,
28 foundry => 'OpenNLP',
29 layer => 'Tokens',
30 name => 'tokens'
31 )
32};
33
34is($doc->primary->data,
35 'Zum letzten kulturellen Anlass lädt die Leitung des Schulheimes Hofbergli ein, '.
36 'bevor der Betrieb Ende Schuljahr eingestellt wird.', 'Primary data');
37
38is($doc->primary->data_length, 129, 'Primary data length');
39
40is($doc->primary->data(0,3), 'Zum', 'Get primary data');
41
42# Get tokens
43use_ok('KorAP::Tokenizer');
44# Get tokenization
45ok(my $tokens = KorAP::Tokenizer->new(
46 path => $doc->path,
47 doc => $doc,
48 foundry => 'OpenNLP',
49 layer => 'Tokens',
50 name => 'tokens'
51), 'New Tokenizer');
52ok($tokens->parse, 'Parse');
53
54ok($tokens->add_subtokens, 'Add subtokens');
55
56# diag $tokens->to_string;
57
58#foreach (@{$tokens->stream->multi_term_tokens}) {
59# print $_;
60#};
61
62done_testing;
63
64
65__END__