read lexeme info in GraphML parsing
[scpubgit/stemmatology.git] / lib / Text / Tradition / Collation / Reading / WordForm.pm
index 4c81929..46a9f80 100644 (file)
@@ -1,6 +1,7 @@
 package Text::Tradition::Collation::Reading::WordForm;
 
 use Moose;
+use Lingua::Features::Structure;
 
 =head1 NAME
 
@@ -61,6 +62,19 @@ has 'morphology' => (
        required => 1,
        );
        
+around BUILDARGS => sub {
+       my $orig = shift;
+       my $class = shift;
+       my $args = @_ == 1 ? $_[0] : { @_ };
+       if( exists $args->{'serial'} ) {
+               my( $lang, $lemma, $morph ) = split( /\+\+/, delete $args->{'serial'} );
+               $args->{'language'} = $lang;
+               $args->{'lemma'} = $lemma;
+               $args->{'morphology'} = Lingua::Features::Structure->from_string( $morph );
+       }
+       $class->$orig( $args );
+};
+       
 =head2 to_string
 
 Returns a string combination of language/lemma/morphology that can be used