X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition%2FCollation%2FReading%2FWordForm.pm;h=4335857fdb1c6516d84435d14d0a466d5bc5b1c3;hb=da83693e61ca80c4c9a23583a0aadda94d087125;hp=6a6b56bf60ca85ee8e1f02a80f2183e920fcca7a;hpb=7604424bc5cc004f536d20099d9d348aa922ce7d;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition/Collation/Reading/WordForm.pm b/lib/Text/Tradition/Collation/Reading/WordForm.pm index 6a6b56b..4335857 100644 --- a/lib/Text/Tradition/Collation/Reading/WordForm.pm +++ b/lib/Text/Tradition/Collation/Reading/WordForm.pm @@ -68,10 +68,12 @@ around BUILDARGS => sub { my $class = shift; my $args = @_ == 1 ? $_[0] : { @_ }; if( exists $args->{'JSON'} ) { - my $data = $args->{'JSON'}; - my $morph = Lingua::Features::Structure->from_string( $data->{'morphology'} ); - $data->{'morphology'} = $morph; - $args = $data; + $DB::single = 1; + my @data = split( / \/\/ /, $args->{'JSON'} ); + print STDERR "Attempting to parse " . $data[2] . " into structure"; + my $morph = Lingua::Features::Structure->from_string( $data[2] ); + $args = { 'language' => $data[0], 'lemma' => $data[1], + 'morphology' => $morph }; } $class->$orig( $args ); }; @@ -88,13 +90,12 @@ sub to_string { return JSON->new->convert_blessed(1)->encode( $self ); } +# Rather than spitting it out as a JSON hash, encode it as a string so that +# the XML serialization doesn't become insane. sub TO_JSON { my $self = shift; - return { - 'language' => $self->language, - 'lemma' => $self->lemma, - 'morphology' => $self->morphology->to_string - }; + return sprintf( "%s // %s // %s", $self->language, $self->lemma, + $self->morphology->to_string() ); } no Moose;