remove 'meaning' relationship; apply fix to make ellipse text draggable
[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 lexical
7                                                            collated repetition transposition );
8
9 enum 'RelationshipScope' => qw( local document 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, lexical, 
35 collated, repetition, transposition.  All but the last two are only valid 
36 relationships between readings that occur at the same point in the text. 
37 The 'collated' relationship should only be used by parsers to align readings 
38 in the graph when the input information would otherwise be lost, e.g. from
39 an alignment table.
40
41 =item * displayform - (Optional) The reading that should be displayed if the 
42 related nodes are treated as one.
43
44 =item * scope - (Optional) A meta-attribute.  Can be one of 'local', 
45 'document', or 'global'. Denotes whether the relationship between the two 
46 readings holds always, independent of context, either within this tradition 
47 or across all traditions.
48
49 =item * annotation - (Optional) A freeform note to attach to the relationship.
50
51 =item * non_correctable - (Optional) True if the reading would not have been 
52 corrected independently.
53
54 =item * non_independent - (Optional) True if the variant is unlikely to have 
55 occurred independently in unrelated witnesses.
56
57 =back
58
59 =head1 ACCESSORS
60
61 =head2 type
62
63 =head2 displayform
64
65 =head2 scope
66
67 =head2 annotation
68
69 =head2 non_correctable
70
71 =head2 non_independent
72
73 See the option descriptions above.
74
75 =cut
76
77 has 'type' => (
78         is => 'ro',
79         isa => 'RelationshipType',
80         required => 1,
81         );
82
83 has 'reading_a' => (
84         is => 'ro',
85         isa => 'Str',
86         required => 1,
87         );
88
89 has 'reading_b' => (
90         is => 'ro',
91         isa => 'Str',
92         required => 1,
93         );
94
95 has 'displayform' => (
96         is => 'ro',
97         isa => 'Str',
98         predicate => 'has_displayform',
99         );
100
101 has 'scope' => (
102         is => 'ro',
103         isa => 'RelationshipScope', 
104         default => 'local',
105         );
106         
107 has 'annotation' => (
108         is => 'ro',
109         isa => 'Str',
110         predicate => 'has_annotation',
111         );
112
113 has 'non_correctable' => (
114         is => 'ro',
115         isa => 'Bool',
116         );
117
118 has 'non_independent' => (
119         is => 'ro',
120         isa => 'Bool',
121         );
122         
123 # A read-only meta-Boolean attribute.
124
125 =head2 colocated
126
127 Returns true if the relationship type is one that requires that its readings
128 occupy the same place in the collation.
129
130 =cut
131
132 sub colocated {
133         my $self = shift;
134         return $self->type !~ /^(repetition|transposition)$/;
135 }
136
137 =head2 nonlocal
138
139 Returns true if the relationship scope is anything other than 'local'.
140
141 =cut
142
143 sub nonlocal {
144         my $self = shift;
145         return $self->scope ne 'local';
146 }
147
148 no Moose;
149 __PACKAGE__->meta->make_immutable;
150
151 1;