generalize Latin module to Latin/Greek/Armenian on Perseus
[scpubgit/stemmatology.git] / lib / Text / Tradition / Language / Latin.pm
CommitLineData
5271a011 1package Text::Tradition::Language::Latin;
2
3use strict;
4use warnings;
5use Module::Load;
0ce8c0cf 6use parent qw/ Text::Tradition::Language::Perseus /;
5271a011 7
8=head1 NAME
9
10Text::Tradition::Language::Latin - language-specific module for Latin
11
12=head1 DESCRIPTION
13
0ce8c0cf 14Implements morphology lookup for Latin words in context. This module
f8862b58 15depends on the Lingua::Morph::Perseus module for access to PhiloLogic database data.
5271a011 16
17=head1 SUBROUTINES
18
19=head2 lemmatize( $text )
20
0ce8c0cf 21Evaluates the string using Treetagger and Perseus, and returns the results.
5271a011 22
23=begin testing
24
25use Text::Tradition;
26use_ok( 'Text::Tradition::Language::Latin' );
27
f8862b58 28eval "use Lingua::Morph::Perseus";
5271a011 29my $err = $@;
30
31SKIP: {
f8862b58 32 skip "Package Lingua::Morph::Perseus not found" if $err;
5271a011 33
34 my $trad = Text::Tradition->new(
35 'language' => 'Latin',
36 'file' => 't/data/legendfrag.xml',
37 'input' => 'Self' );
38 $trad->lemmatize();
39 my $ambig = 0;
40 foreach my $r ( $trad->collation->readings ) {
41 next if $r->is_meta;
42 ok( $r->has_lexemes, "Reading $r has one or more lexemes" );
43 my @lex = $r->lexemes;
44 my $lexstr = join( '', map { $_->string } @lex );
45 my $textstr = $r->text;
46 $textstr =~ s/\s+//g;
47 is( $textstr, $lexstr, "Lexemes for reading $r match the reading" );
48 foreach my $l ( @lex ) {
fe77efe0 49 next unless $l->matches;
5271a011 50 next if $l->is_disambiguated;
51 printf( "Ambiguous lexeme %s for reading %s:\n\t%s\n", $l->string, $r->id,
52 join( "\n\t", map { $_->lemma . ': ' . $_->morphology->to_string } $l->matching_forms ) );
53 $ambig++;
54 }
55 }
f8862b58 56 is( $ambig, 4, "Found 4 ambiguous forms as expected" );
5271a011 57}
58
59=end testing
60
61=cut
62
0ce8c0cf 63our $dbhandle;
64
5271a011 65sub lemmatize {
0ce8c0cf 66 return __PACKAGE__->perseus_lemmatize( @_ );
5271a011 67}
68
5271a011 69sub reading_lookup {
0ce8c0cf 70 return __PACKAGE__->perseus_reading_lookup( @_ );
75ae2b25 71}
72
227d4a11 731;