1 package Text::Tradition::Collation::Reading::Lexeme;
8 Text::Tradition::Collation::Reading::Lexeme - represents the components of
13 Text::Tradition is a library for representation and analysis of collated
14 texts, particularly medieval ones. A word form is used for the analysis of
15 Reading objects; it consists of a lemma, a language, and a code to
16 represent its part of speech. In general the word forms for a particular
17 language should be read from / written to some morphological database.
23 Creates a new lexeme from the passed options.
27 Returns the language to which this lexeme belongs.
31 Returns the canonical string version of this lexeme.
35 Returns the number of possible word forms for this lexeme, as drawn from
36 the appropriate database.
40 Returns an array of the possible word forms for this lexeme.
42 =head2 matching_form( $index )
44 Returns the form at $index in the list of matching forms.
46 =head2 is_disambiguated
48 Returns true if a single wordform has been picked as 'correct' for this
49 lexeme in its context.
53 Returns the correct word form (if any has been selected) for the lexeme in
58 # TODO need to be able to populate this from DB
71 has 'wordform_matchlist' => (
72 isa => 'ArrayRef[Text::Tradition::Collation::Reading::WordForm]',
76 'matching_forms' => 'elements',
77 'matching_form' => 'get',
78 'add_matching_form' => 'push',
81 has 'is_disambiguated' => (
85 writer => '_set_disambiguated',
90 isa => 'Text::Tradition::Collation::Reading::WordForm',
91 writer => '_set_form',
95 =head2 disambiguate( $index )
97 Selects the word form at $index in the list of matching forms, and asserts
98 that this is the correct form for the lexeme.
103 my( $self, $idx ) = @_;
104 my $form = $self->matching_form( $idx );
105 throw( "There is no candidate wordform at index $idx" )
107 $self->_set_form( $form );
108 $self->_set_disambiguated( 1 );
113 Uses the module for the declared language to look up the lexeme in the
114 language database (if any.) Sets the returned morphological matches in
115 matching_forms, and returns the list as an array of WordForm objects.
121 my $lang = $self->language;
124 my $langmod = "Text::Tradition::Language::$lang";
126 @answers = $langmod->can( 'word_lookup' )->( $self->string );
128 throw( "No language module for $lang, or the module has no word_lookup functionality" );
130 $self->clear_matching_forms;
131 $self->add_matching_form( @answers );
136 __PACKAGE__->meta->make_immutable;
142 This package is free software and is provided "as is" without express
143 or implied warranty. You can redistribute it and/or modify it under
144 the same terms as Perl itself.
148 Tara L Andrews E<lt>aurum@cpan.orgE<gt>