keep analysis scripts out of CPAN; make CHANGES file; increment versions for release
[scpubgit/stemmatology.git] / morphology / t / lexeme_serialize.t
CommitLineData
70745e70 1use lib 'lib';
2use strict;
3use warnings;
951ddfe8 4use Safe::Isa;
70745e70 5use Test::More;
6use Text::Tradition;
7
8eval "use Flemm";
9plan skip_all => "Flemm 3.1 required" if $@;
10
11binmode( STDOUT, ':utf8' );
12binmode( STDERR, ':utf8' );
13
14my $tf = Text::Tradition->new(
15 'input' => 'Self',
16 'file' => 't/data/besoin.xml',
17 'language' => 'French' );
18
19$tf->lemmatize();
20my $graphmlstr = $tf->collation->as_graphml;
21like( $graphmlstr, qr/graphml xmlns/,
22 "Serialized tradition after lemmatization" );
a445ce40 23like( $graphmlstr, qr/lexemes/, "Serialization contains lexeme info" );
70745e70 24
25my $tf2 = Text::Tradition->new(
26 input => 'Self',
27 string => $graphmlstr,
28 language => 'French' );
29
951ddfe8 30ok( $tf2->$_isa('Text::Tradition'), "Re-parsed tradition with lemmatization" );
70745e70 31is( $tf->name, $tf2->name, "Traditions have same name" );
32foreach my $r ( $tf->collation->readings ) {
33 my $r2 = $tf2->collation->reading( $r->id );
951ddfe8 34 ok( $r2->$_isa('Text::Tradition::Collation::Reading'),
70745e70 35 "Reading $r exists in new tradition" );
36 if( $r2 ) {
37 is( scalar $r->lexemes, scalar $r2->lexemes,
38 "Same number of lexemes in new tradition for $r" );
39 }
40}
41
6ba69acd 42# Test a snippet of tradition with possibly-problematic saved lexemes
43my $tf3 = Text::Tradition->new(
44 'input' => 'Self',
45 'file' => 't/data/lexformat.xml' );
951ddfe8 46ok( $tf3->$_isa('Text::Tradition'),
6ba69acd 47 "Successfully parsed tradition with incomplete lexemes" );
48
70745e70 49done_testing();