X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition%2FCollation.pm;h=a77f74f519bd6b7d7e7c2ee78e9a4bd129c5ed10;hb=7cd9f181280b397e3ef6c95845270d48368fc11f;hp=cc26b0e475f8c5069f3f6a7ab4b0451462feaa8b;hpb=04482188230a9be8e9a1335dbfcd8e3160a5768d;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition/Collation.pm b/lib/Text/Tradition/Collation.pm index cc26b0e..a77f74f 100644 --- a/lib/Text/Tradition/Collation.pm +++ b/lib/Text/Tradition/Collation.pm @@ -974,6 +974,9 @@ sub as_graphml { next unless $save_types{$attr->type_constraint->name}; $reading_attributes{$attr->name} = $save_types{$attr->type_constraint->name}; } + # Extra custom key for the reading morphology + $reading_attributes{'lexemes'} = 'string'; + my %node_data_keys; my $ndi = 0; foreach my $datum ( sort keys %reading_attributes ) { @@ -1052,6 +1055,13 @@ sub as_graphml { $node_el->setAttribute( 'id', $node_xmlid ); foreach my $d ( keys %reading_attributes ) { my $nval = $n->$d; + # Custom serialization + if( $d eq 'lexemes' ) { + # If nval is a true value, we have lexemes so we need to + # serialize them. Otherwise set nval to undef so that the + # key is excluded from this reading. + $nval = $nval ? $n->_serialize_lexemes : undef; + } if( $rankoffset && $d eq 'rank' && $n ne $self->start ) { # Adjust the ranks within the subgraph. $nval = $n eq $self->end ? $end->rank - $rankoffset + 1