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