Commit | Line | Data |
6ad2ce78 |
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 | binmode STDOUT, ':utf8'; |
12 | use Text::Tradition; |
13 | use_ok( 'Text::Tradition::Language::French' ); |
14 | |
15 | eval "use Flemm"; |
16 | my $err = $@; |
17 | |
18 | SKIP: { |
19 | skip "Package Flemm not found" if $err; |
20 | my $tf = Text::Tradition->new( |
21 | 'input' => 'Self', |
22 | 'file' => 't/data/besoin.xml', |
23 | 'language' => 'French' ); |
24 | |
25 | is( $tf->language, 'French', "Set language okay" ); |
26 | $tf->lemmatize(); |
27 | # Test the lemmatization. How many readings now have morphological info? |
28 | # Do the lexemes match the reading? |
29 | my $ambig = 0; |
30 | foreach my $r ( $tf->collation->readings ) { |
31 | next if $r->is_meta; |
32 | ok( $r->has_lexemes, "Reading $r has one or more lexemes" ); |
33 | my @lex = $r->lexemes; |
34 | my $lexstr = join( '', map { $_->string } @lex ); |
35 | my $textstr = $r->text; |
36 | $textstr =~ s/\s+//g; |
37 | is( $textstr, $lexstr, "Lexemes for reading $r match the reading" ); |
38 | foreach my $l ( @lex ) { |
39 | next if $l->is_disambiguated; |
40 | # printf( "Ambiguous lexeme %s for reading %s:\n\t%s\n", $l->string, $r->id, |
41 | # join( "\n\t", map { $_->lemma . ': ' . $_->morphology->to_string } $l->matching_forms ) ); |
42 | $ambig++; |
43 | } |
44 | } |
45 | is( $ambig, 102, "Found 102 ambiguous forms as expected" ); |
46 | |
47 | # Try setting the normal form of a reading and re-analyzing |
e0f6836a |
48 | my $mr = $tf->collation->reading('r99.2'); |
6ad2ce78 |
49 | is( $mr->text, 'minspire', "Picked correct test reading" ); |
50 | is( $mr->language, 'French', "Reading has correct language setting" ); |
51 | $mr->normal_form( "m'inspire" ); |
52 | $mr->lemmatize; |
53 | is( $mr->lexemes, 2, "Got two lexemes for new m'inspire reading" ); |
54 | } |
55 | } |
56 | |
57 | |
58 | |
59 | |
60 | 1; |