1 package Text::Tradition::Collation::Reading::WordForm;
3 use Lingua::Features::Structure;
9 Text::Tradition::Collation::Reading::WordForm - represents a
10 language/lemma/morphology triplet that can be associated with a Reading.
14 Text::Tradition is a library for representation and analysis of collated
15 texts, particularly medieval ones. A word form is used for the analysis of
16 Reading objects; it consists of a lemma, a language, and a code to
17 represent its part of speech. In general the word forms for a particular
18 language should be read from / written to some morphological database.
24 Creates a new word form from the passed options.
28 Returns the language to which this word form belongs.
32 Returns the lemma for the word form.
36 Returns an array representing this word's morphology. The contents of the
37 array depend on the language being used.
47 # TODO do we need this?
62 isa => 'Lingua::Features::Structure',
66 around BUILDARGS => sub {
69 my $args = @_ == 1 ? $_[0] : { @_ };
70 if( exists $args->{'JSON'} ) {
71 my @data = split( / \/\/ /, $args->{'JSON'} );
72 # print STDERR "Attempting to parse " . $data[2] . " into structure";
73 my $morph = Lingua::Features::Structure->from_string( $data[2] );
74 $args = { 'language' => $data[0], 'lemma' => $data[1],
75 'morphology' => $morph };
77 $class->$orig( $args );
82 Returns a string combination of language/lemma/morphology that can be used
83 in equivalence testing.
89 return JSON->new->convert_blessed(1)->encode( $self );
92 # Rather than spitting it out as a JSON hash, encode it as a string so that
93 # the XML serialization doesn't become insane.
96 return sprintf( "%s // %s // %s", $self->language, $self->lemma,
97 $self->morphology->to_string() );
101 __PACKAGE__->meta->make_immutable;
107 This package is free software and is provided "as is" without express
108 or implied warranty. You can redistribute it and/or modify it under
109 the same terms as Perl itself.
113 Tara L Andrews E<lt>aurum@cpan.orgE<gt>