4e9d60288fd99bbfe30c45cb3d2e38b9643929b2
[scpubgit/stemmatology.git] / t / text_tradition_language_latin.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Test::More 'no_plan';
5 $| = 1;
6
7
8
9 # =begin testing
10 {
11 use Text::Tradition;
12 use_ok( 'Text::Tradition::Language::Latin' );
13
14 eval "use Morph::Perseus";
15 my $err = $@;
16
17 SKIP: {
18         skip "Package Morph::Perseus not found" if $err;
19
20         my $trad = Text::Tradition->new(
21                 'language' => 'Latin',
22                 'file' => 't/data/legendfrag.xml',
23                 'input' => 'Self' );
24         $trad->lemmatize();
25         my $ambig = 0;
26         foreach my $r ( $trad->collation->readings ) {
27                 next if $r->is_meta;
28                 ok( $r->has_lexemes, "Reading $r has one or more lexemes" );
29                 my @lex = $r->lexemes;
30                 my $lexstr = join( '', map { $_->string } @lex );
31                 my $textstr = $r->text;
32                 $textstr =~ s/\s+//g;
33                 is( $textstr, $lexstr, "Lexemes for reading $r match the reading" );
34                 foreach my $l ( @lex ) {
35                         next if $l->is_disambiguated;
36                         printf( "Ambiguous lexeme %s for reading %s:\n\t%s\n", $l->string, $r->id,
37                                 join( "\n\t", map { $_->lemma . ': ' . $_->morphology->to_string } $l->matching_forms ) );
38                         $ambig++;
39                 }
40         }
41         is( $ambig, 19, "Found 19 ambiguous forms as expected" );
42 }
43 }
44
45
46
47
48 1;