1 package Text::Tradition::Language::Latin;
6 use parent qw/ Text::Tradition::Language::Perseus /;
10 Text::Tradition::Language::Latin - language-specific module for Latin
14 Implements morphology lookup for Latin words in context. This module
15 depends on the Lingua::Morph::Perseus module for access to PhiloLogic database data.
19 =head2 lemmatize( $text )
21 Evaluates the string using Treetagger and Perseus, and returns the results.
23 =head2 reading_lookup( $word )
25 Returns a single-word morphological lookup of the given word using Perseus.
30 use_ok( 'Text::Tradition::Language::Latin' );
32 my $trad = Text::Tradition->new(
33 'language' => 'Latin',
34 'file' => 't/data/legendfrag.xml',
37 eval "use Lingua::Morph::Perseus";
40 skip "Package Lingua::Morph::Perseus not found" if $err;
44 foreach my $r ( $trad->collation->readings ) {
46 ok( $r->has_lexemes, "Reading $r has one or more lexemes" );
47 my @lex = $r->lexemes;
48 my $lexstr = join( '', map { $_->string } @lex );
49 my $textstr = $r->text;
51 is( $textstr, $lexstr, "Lexemes for reading $r match the reading" );
52 foreach my $l ( @lex ) {
53 next unless $l->matches;
54 next if $l->is_disambiguated;
55 printf( "Ambiguous lexeme %s for reading %s:\n\t%s\n", $l->string, $r->id,
56 join( "\n\t", map { $_->lemma . ': ' . $_->morphology->to_string } $l->matching_forms ) );
60 is( $ambig, 4, "Found 4 ambiguous forms as expected" );
63 # Try exporting some witnesses
64 my $e_v = 'in suetia uenerabilis pontifex beatus henricus in anglia oriundus';
65 my $struct_v = $trad->witness('V')->export_as_json;
66 my $g_v = join( ' ', map { $_->{'n'} } @{$struct_v->{'tokens'}} );
67 is( $g_v, $e_v, "Got expected regularization of witness V" );
68 my $e_n = 'in suetia beatus henricus uenerabilis pontifex de anglia oriundus';
69 my $struct_n = $trad->witness('N')->export_as_json;
70 my $g_n = join( ' ', map { $_->{'n'} } @{$struct_n->{'tokens'}} );
71 is( $g_n, $e_n, "Got expected regularization of witness N" );
81 return __PACKAGE__->perseus_lemmatize( @_ );
85 return __PACKAGE__->perseus_reading_lookup( @_ );
88 =head2 regularize( $text )
90 Returns a regularized form of the reading for the purposes of collation.