Commit | Line | Data |
cca4f996 |
1 | package Text::Tradition::Collation::Reading::WordForm; |
2 | |
3 | use Moose; |
4 | |
5 | =head1 NAME |
6 | |
7 | Text::Tradition::Collation::Reading::WordForm - represents a |
8 | language/lemma/morphology triplet that can be associated with a Reading. |
9 | |
10 | =head1 DESCRIPTION |
11 | |
12 | Text::Tradition is a library for representation and analysis of collated |
13 | texts, particularly medieval ones. A word form is used for the analysis of |
14 | Reading objects; it consists of a lemma, a language, and a code to |
15 | represent its part of speech. In general the word forms for a particular |
16 | language should be read from / written to some morphological database. |
17 | |
18 | =head1 METHODS |
19 | |
20 | =head2 new |
21 | |
22 | Creates a new word form from the passed options. |
23 | |
24 | =head2 language |
25 | |
26 | Returns the language to which this word form belongs. |
27 | |
28 | =head2 lemma |
29 | |
30 | Returns the lemma for the word form. |
31 | |
32 | =head2 morphology |
33 | |
34 | Returns an array representing this word's morphology. The contents of the |
35 | array depend on the language being used. |
36 | |
37 | =cut |
38 | |
39 | has 'language' => ( |
40 | is => 'ro', |
41 | isa => 'Str', |
42 | required => 1, |
43 | ); |
44 | |
45 | # TODO do we need this? |
46 | has 'form' => ( |
47 | is => 'ro', |
48 | isa => 'Str', |
49 | # required => 1, |
50 | ); |
51 | |
52 | has 'lemma' => ( |
53 | is => 'ro', |
54 | isa => 'Str', |
55 | required => 1, |
56 | ); |
57 | |
58 | has 'morphology' => ( |
59 | is => 'ro', |
6ad2ce78 |
60 | isa => 'Lingua::Features::Structure', |
cca4f996 |
61 | required => 1, |
62 | ); |
63 | |
6ad2ce78 |
64 | =head2 to_string |
65 | |
66 | Returns a string combination of language/lemma/morphology that can be used |
67 | in equivalence testing. |
68 | |
69 | =cut |
70 | |
71 | sub to_string { |
cca4f996 |
72 | my $self = shift; |
6ad2ce78 |
73 | return join( '++', $self->language, $self->lemma, $self->morphology->to_string ); |
cca4f996 |
74 | } |
6ad2ce78 |
75 | |
cca4f996 |
76 | no Moose; |
77 | __PACKAGE__->meta->make_immutable; |
78 | |
79 | 1; |
80 | |
81 | =head1 LICENSE |
82 | |
83 | This package is free software and is provided "as is" without express |
84 | or implied warranty. You can redistribute it and/or modify it under |
85 | the same terms as Perl itself. |
86 | |
87 | =head1 AUTHOR |
88 | |
89 | Tara L Andrews E<lt>aurum@cpan.orgE<gt> |