generalize Latin module to Latin/Greek/Armenian on Perseus
[scpubgit/stemmatology.git] / lib / Text / Tradition / Language / Greek.pm
1 package Text::Tradition::Language::Greek;
2
3 use strict;
4 use warnings;
5 use Module::Load;
6 use parent qw/ Text::Tradition::Language::Perseus /;
7
8 =head1 NAME
9
10 Text::Tradition::Language::Greek - language-specific module for Greek
11
12 =head1 DESCRIPTION
13
14 Implements morphology lookup for Greek words in context.  This module
15 depends on the Lingua::Morph::Perseus module for access to PhiloLogic database data.
16
17 =head1 SUBROUTINES
18
19 =head2 lemmatize( $text )
20
21 Evaluates the string using Treetagger and Perseus, and returns the results.
22
23 =begin testing
24
25 use Text::Tradition;
26 use_ok( 'Text::Tradition::Language::Greek' );
27
28 eval "use Lingua::Morph::Perseus";
29 my $err = $@;
30
31 SKIP: {
32         skip "Greek linguistic data not read yet";
33
34         my $trad = Text::Tradition->new(
35                 'language' => 'Greek',
36                 'file' => 't/data/florilegium_graphml.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 ) {
49                         next unless $l->matches;
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         }
56         is( $ambig, 4, "Found 4 ambiguous forms as expected" );
57 }
58
59 =end testing
60
61 =cut
62
63 our $dbhandle;
64
65 sub lemmatize {
66         return __PACKAGE__->perseus_lemmatize( @_ );
67 }
68
69 sub reading_lookup {
70         return __PACKAGE__->perseus_reading_lookup( @_ );
71 }
72
73 1;