blob: f119a2bf02838b5724dfe4702b51af63080bcbf9 [file] [log] [blame]
Nils Diewald6c44f422014-10-31 02:16:14 +00001#!/usr/bin/env perl
2# source ~/perl5/perlbrew/etc/bashrc
3# perlbrew switch perl-blead@korap
4use strict;
5use warnings;
6use Test::More;
7
8use Benchmark qw/:hireswallclock/;
9
10my $t = Benchmark->new;
11
12use utf8;
13use lib 'lib', '../lib';
14
Nils Diewald6c44f422014-10-31 02:16:14 +000015use File::Basename 'dirname';
16use File::Spec::Functions 'catdir';
17
18use_ok('KorAP::Document');
19
20# GOE/AGA/03828
21my $path = catdir(dirname(__FILE__), 'GOE/AGA/03828');
22
23ok(my $doc = KorAP::Document->new( path => $path . '/' ), 'Load Korap::Document');
24ok($doc->parse, 'Parse document');
25
26# Tokenization
27use_ok('KorAP::Tokenizer');
28
29my ($token_base_foundry, $token_base_layer) = (qw/OpenNLP Tokens/);
30
31# Get tokenization
32my $tokens = KorAP::Tokenizer->new(
33 path => $doc->path,
34 doc => $doc,
35 foundry => $token_base_foundry,
36 layer => $token_base_layer,
37 name => 'tokens'
38);
39ok($tokens, 'Token Object is fine');
40ok($tokens->parse, 'Token parsing is fine');
Nils Diewald207439c2014-11-01 00:16:38 +000041
Nils Diewald6c44f422014-10-31 02:16:14 +000042ok($tokens->add('Base', 'Sentences'), 'Add base sentences');
43ok($tokens->add('Base', 'Paragraphs'), 'Add base paragraphs');
44ok($tokens->add('OpenNLP', 'Sentences'), 'Add opennlp sentences');
45ok($tokens->add('OpenNLP', 'Morpho'), 'Add opennlp morpho');
46ok($tokens->add('TreeTagger', 'Sentences'), 'Add tt sentences');
47ok($tokens->add('TreeTagger', 'Morpho'), 'Add tt morpho');
48ok($tokens->add('CoreNLP', 'NamedEntities'), 'Add corenlp ne');
49ok($tokens->add('CoreNLP', 'Sentences'), 'Add corenlp sentences');
50ok($tokens->add('CoreNLP', 'Morpho'), 'Add corenlp morpho');
51ok($tokens->add('CoreNLP', 'Constituency'), 'Add corenlp constituency');
52ok($tokens->add('Glemm', 'Morpho'), 'Add glemm morpho');
53ok($tokens->add('Connexor', 'Sentences'), 'Add cnx sentences');
54ok($tokens->add('Connexor', 'Morpho'), 'Add cnx morpho');
55ok($tokens->add('Connexor', 'Phrase'), 'Add cnx phrase');
56ok($tokens->add('Connexor', 'Syntax'), 'Add cnx syntax');
57ok($tokens->add('Mate', 'Morpho'), 'Add mate morpho');
58# $tokens->add('Mate', 'Dependency');
59ok($tokens->add('XIP', 'Sentences'), 'Add xip sentences');
60ok($tokens->add('XIP', 'Morpho'), 'Add xip morpho');
61ok($tokens->add('XIP', 'Constituency'), 'Add xip constituency');
62# $tokens->add('XIP', 'Dependency');
63ok($tokens->to_json, 'To json');
64
Nils Diewald207439c2014-11-01 00:16:38 +000065is($tokens->doc->to_hash->{title}, 'Autobiographische Einzelheiten');
66
Nils Diewald6c44f422014-10-31 02:16:14 +000067diag timestr(timediff(Benchmark->new, $t));