efefaab52d92e76d8d45ce81dfaf91e9d109a03f
[scpubgit/stemmatology.git] / lib / Text / Tradition / Collation / Relationship.pm
1 package Text::Tradition::Collation::Relationship;
2
3 use Moose;
4 use Moose::Util::TypeConstraints;
5
6 enum 'RelationshipType' => qw( spelling orthographic grammatical meaning lexical
7                                                            collated repetition transposition );
8
9 enum 'RelationshipScope' => qw( local tradition global );
10
11 no 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
17 =item * displayform - (Optional) The reading that should be displayed if the related nodes are treated as one.
18
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
29 has 'type' => (
30         is => 'ro',
31         isa => 'RelationshipType',
32         required => 1,
33         );
34
35 has 'reading_a' => (
36         is => 'ro',
37         isa => 'Str',
38         required => 1,
39         );
40
41 has 'reading_b' => (
42         is => 'ro',
43         isa => 'Str',
44         required => 1,
45         );
46
47 has 'displayform' => (
48         is => 'ro',
49         isa => 'Str',
50         predicate => 'has_displayform',
51         );
52
53 has 'scope' => (
54         is => 'ro',
55         isa => 'RelationshipScope', 
56         default => 'local',
57         );
58
59 has 'non_correctable' => (
60         is => 'ro',
61         isa => 'Bool',
62         predicate => 'noncorr_set',
63         );
64
65 has 'non_independent' => (
66         is => 'ro',
67         isa => 'Bool',
68         predicate => 'nonind_set',
69         );
70         
71 # A read-only meta-Boolean attribute.
72 sub colocated {
73         my $self = shift;
74         return $self->type !~ /^(repetition|transposition)$/;
75 }
76
77 sub nonlocal {
78         my $self = shift;
79         return $self->scope ne 'local';
80 }
81
82 no Moose;
83 __PACKAGE__->meta->make_immutable;
84
85 1;