huge pile of pod updates
[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 =head1 NAME
14
15 Text::Tradition::Collation::Relationship - represents a syntactic or semantic
16 relationship between two readings
17     
18 =head1 DESCRIPTION
19
20 Text::Tradition is a library for representation and analysis of collated
21 texts, particularly medieval ones.  A relationship connects two readings
22 within a collation, usually when they appear in the same place in different
23 texts.
24
25 =head1 CONSTRUCTOR
26
27 =head2 new
28
29 Creates a new relationship. Usually called via $collation->add_relationship.
30 Options include:
31
32 =over 4
33
34 =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.
35
36 =item * displayform - (Optional) The reading that should be displayed if the related nodes are treated as one.
37
38 =item * non_correctable - (Optional) True if the reading would not have been corrected independently.
39
40 =item * non_independent - (Optional) True if the variant is unlikely to have occurred independently in unrelated witnesses.
41
42 =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.
43
44 =back
45
46 =head1 ACCESSORS
47
48 =head2 type
49
50 =head2 displayform
51
52 =head2 scope
53
54 =head2 non_correctable
55
56 =head2 non_independent
57
58 See the option descriptions above.
59
60 =cut
61
62 has 'type' => (
63         is => 'ro',
64         isa => 'RelationshipType',
65         required => 1,
66         );
67
68 has 'reading_a' => (
69         is => 'ro',
70         isa => 'Str',
71         required => 1,
72         );
73
74 has 'reading_b' => (
75         is => 'ro',
76         isa => 'Str',
77         required => 1,
78         );
79
80 has 'displayform' => (
81         is => 'ro',
82         isa => 'Str',
83         predicate => 'has_displayform',
84         );
85
86 has 'scope' => (
87         is => 'ro',
88         isa => 'RelationshipScope', 
89         default => 'local',
90         );
91
92 has 'non_correctable' => (
93         is => 'ro',
94         isa => 'Bool',
95         predicate => 'noncorr_set',
96         );
97
98 has 'non_independent' => (
99         is => 'ro',
100         isa => 'Bool',
101         predicate => 'nonind_set',
102         );
103         
104 # A read-only meta-Boolean attribute.
105
106 =head2 colocated
107
108 Returns true if the relationship type is one that requires that its readings
109 occupy the same place in the collation.
110
111 =cut
112
113 sub colocated {
114         my $self = shift;
115         return $self->type !~ /^(repetition|transposition)$/;
116 }
117
118 =head2 nonlocal
119
120 Returns true if the relationship scope is anything other than 'local'.
121
122 =cut
123
124 sub nonlocal {
125         my $self = shift;
126         return $self->scope ne 'local';
127 }
128
129 no Moose;
130 __PACKAGE__->meta->make_immutable;
131
132 1;