initialize stemma array in tradition
[scpubgit/stemmatology.git] / lib / Text / Tradition / Collation / Relationship.pm
CommitLineData
22222af9 1package Text::Tradition::Collation::Relationship;
2
3use Moose;
4use Moose::Util::TypeConstraints;
5
6enum 'RelationshipType' => qw( spelling orthographic grammatical meaning lexical
c84275ff 7 collated repetition transposition );
22222af9 8
9enum 'RelationshipScope' => qw( local tradition global );
10
11no Moose::Util::TypeConstraints;
12
13=over 4
14
15=item * type - Can be one of spelling, orthographic, grammatical, meaning, lexical, collated, repetition, transposition. All but the last two are only valid relationships between readings that occur at the same point in the text.
16
732e9c4e 17=item * displayform - (Optional) The reading that should be displayed if the related nodes are treated as one.
18
22222af9 19=item * non_correctable - (Optional) True if the reading would not have been corrected independently.
20
21=item * non_independent - (Optional) True if the variant is unlikely to have occurred independently in unrelated witnesses.
22
23=item * scope - (Optional) A meta-attribute. Can be one of 'local', 'tradition', or 'global'. Denotes whether the relationship between the two readings holds always, independent of context, either within this tradition or across all traditions.
24
25=back
26
27=cut
28
29has 'type' => (
30 is => 'ro',
31 isa => 'RelationshipType',
32 required => 1,
33 );
34
35has 'reading_a' => (
36 is => 'ro',
37 isa => 'Str',
38 required => 1,
39 );
40
41has 'reading_b' => (
42 is => 'ro',
43 isa => 'Str',
44 required => 1,
45 );
46
732e9c4e 47has 'displayform' => (
48 is => 'ro',
49 isa => 'Str',
50 predicate => 'has_displayform',
51 );
52
22222af9 53has 'scope' => (
54 is => 'ro',
55 isa => 'RelationshipScope',
56 default => 'local',
57 );
58
59has 'non_correctable' => (
60 is => 'ro',
61 isa => 'Bool',
c84275ff 62 predicate => 'noncorr_set',
22222af9 63 );
64
65has 'non_independent' => (
66 is => 'ro',
67 isa => 'Bool',
c84275ff 68 predicate => 'nonind_set',
22222af9 69 );
732e9c4e 70
22222af9 71# A read-only meta-Boolean attribute.
72sub colocated {
73 my $self = shift;
74 return $self->type !~ /^(repetition|transposition)$/;
75}
76
77sub nonlocal {
78 my $self = shift;
79 return $self->scope ne 'local';
80}
81
82no Moose;
83__PACKAGE__->meta->make_immutable;
84
851;