line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Tradition::Collation::Relationship; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
64
|
use Moose; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
76
|
|
4
|
10
|
|
|
10
|
|
72188
|
use Text::Tradition::Datatypes; |
|
10
|
|
|
|
|
27
|
|
|
10
|
|
|
|
|
4277
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Text::Tradition::Collation::Relationship - represents a syntactic or semantic |
9
|
|
|
|
|
|
|
relationship between two readings |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Text::Tradition is a library for representation and analysis of collated |
14
|
|
|
|
|
|
|
texts, particularly medieval ones. A relationship connects two readings |
15
|
|
|
|
|
|
|
within a collation, usually when they appear in the same place in different |
16
|
|
|
|
|
|
|
texts. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 new |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Creates a new relationship. Usually called via $collation->add_relationship. |
23
|
|
|
|
|
|
|
Options include: |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=over 4 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=item * type - Can be one of spelling, orthographic, grammatical, lexical, |
28
|
|
|
|
|
|
|
collated, repetition, transposition. All but the last two are only valid |
29
|
|
|
|
|
|
|
relationships between readings that occur at the same point in the text. |
30
|
|
|
|
|
|
|
The 'collated' relationship should only be used by parsers to align readings |
31
|
|
|
|
|
|
|
in the graph when the input information would otherwise be lost, e.g. from |
32
|
|
|
|
|
|
|
an alignment table. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item * displayform - (Optional) The reading that should be displayed if the |
35
|
|
|
|
|
|
|
related nodes are treated as one. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item * scope - (Optional) A meta-attribute. Can be one of 'local', |
38
|
|
|
|
|
|
|
'document', or 'global'. Denotes whether the relationship between the two |
39
|
|
|
|
|
|
|
readings holds always, independent of context, either within this tradition |
40
|
|
|
|
|
|
|
or across all traditions. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item * annotation - (Optional) A freeform note to attach to the relationship. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item * alters_meaning - Indicate whether, in context, the related words cause |
45
|
|
|
|
|
|
|
the text to have different meanings. Possible values are 0 (no), 1 (slightly), |
46
|
|
|
|
|
|
|
and >1 (yes). |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item * a_derivable_from_b - (Optional) True if the first reading is likely to |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item * b_derivable_from_a - (Optional) True if the second reading is likely to |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item * non_independent - (Optional) True if the variant is unlikely to have |
53
|
|
|
|
|
|
|
occurred independently in unrelated witnesses. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item * is_significant - (Optional) Indicates whether, in the opinion of the scholar, |
56
|
|
|
|
|
|
|
the variation in question is stemmatically significant. Possible values are 'yes', |
57
|
|
|
|
|
|
|
'maybe', and 'no'. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=back |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 ACCESSORS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 type |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 displayform |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 scope |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 annotation |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 a_derivable_from_b |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 b_derivable_from_a |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 non_independent |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 is_significant |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
See the option descriptions above. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
has 'type' => ( |
84
|
|
|
|
|
|
|
is => 'ro', |
85
|
|
|
|
|
|
|
isa => 'Str', |
86
|
|
|
|
|
|
|
required => 1, |
87
|
|
|
|
|
|
|
); |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
has 'reading_a' => ( |
90
|
|
|
|
|
|
|
is => 'ro', |
91
|
|
|
|
|
|
|
isa => 'Str', |
92
|
|
|
|
|
|
|
required => 1, |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
has 'reading_b' => ( |
96
|
|
|
|
|
|
|
is => 'ro', |
97
|
|
|
|
|
|
|
isa => 'Str', |
98
|
|
|
|
|
|
|
required => 1, |
99
|
|
|
|
|
|
|
); |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
has 'displayform' => ( |
102
|
|
|
|
|
|
|
is => 'ro', |
103
|
|
|
|
|
|
|
isa => 'Str', |
104
|
|
|
|
|
|
|
predicate => 'has_displayform', |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
has 'scope' => ( |
108
|
|
|
|
|
|
|
is => 'ro', |
109
|
|
|
|
|
|
|
isa => 'RelationshipScope', |
110
|
|
|
|
|
|
|
default => 'local', |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
has 'annotation' => ( |
114
|
|
|
|
|
|
|
is => 'ro', |
115
|
|
|
|
|
|
|
isa => 'Str', |
116
|
|
|
|
|
|
|
predicate => 'has_annotation', |
117
|
|
|
|
|
|
|
); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
has 'alters_meaning' => ( |
120
|
|
|
|
|
|
|
is => 'rw', |
121
|
|
|
|
|
|
|
isa => 'Int', |
122
|
|
|
|
|
|
|
default => 0, |
123
|
|
|
|
|
|
|
); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
has 'a_derivable_from_b' => ( |
126
|
|
|
|
|
|
|
is => 'ro', |
127
|
|
|
|
|
|
|
isa => 'Bool', |
128
|
|
|
|
|
|
|
); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
has 'b_derivable_from_a' => ( |
131
|
|
|
|
|
|
|
is => 'ro', |
132
|
|
|
|
|
|
|
isa => 'Bool', |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
has 'non_independent' => ( |
136
|
|
|
|
|
|
|
is => 'ro', |
137
|
|
|
|
|
|
|
isa => 'Bool', |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
has 'is_significant' => ( |
141
|
|
|
|
|
|
|
is => 'ro', |
142
|
|
|
|
|
|
|
isa => 'Ternary', |
143
|
|
|
|
|
|
|
default => 'no', |
144
|
|
|
|
|
|
|
); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
around 'alters_meaning' => sub { |
147
|
|
|
|
|
|
|
my $orig = shift; |
148
|
|
|
|
|
|
|
my $self = shift; |
149
|
|
|
|
|
|
|
if( @_ ) { |
150
|
|
|
|
|
|
|
if( $_[0] eq 'no' ) { |
151
|
|
|
|
|
|
|
return $self->$orig( 0 ); |
152
|
|
|
|
|
|
|
} elsif( $_[0] eq 'slightly' ) { |
153
|
|
|
|
|
|
|
return $self->$orig( 1 ); |
154
|
|
|
|
|
|
|
} elsif( $_[0] eq 'yes' ) { |
155
|
|
|
|
|
|
|
return $self->$orig( 2 ); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
return $self->$orig( @_ ); |
159
|
|
|
|
|
|
|
}; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# A read-only meta-Boolean attribute. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head2 colocated |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Returns true if the relationship type is one that requires that its readings |
166
|
|
|
|
|
|
|
occupy the same place in the collation. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub colocated { |
171
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
172
|
0
|
|
|
|
|
|
return $self->type !~ /^(repetition|transposition)$/; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 nonlocal |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Returns true if the relationship scope is anything other than 'local'. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub nonlocal { |
182
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
183
|
0
|
|
|
|
|
|
return $self->scope ne 'local'; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 is_equivalent( $otherrel ) |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Returns true if the type and scope of $otherrel match ours. |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub is_equivalent { |
193
|
0
|
|
|
0
|
1
|
|
my( $self, $other, $check_ann ) = @_; |
194
|
0
|
|
0
|
|
|
|
my $oksofar = $self->type eq $other->type && $self->scope eq $other->scope; |
195
|
0
|
0
|
|
|
|
|
if( $check_ann ) { |
196
|
0
|
|
0
|
|
|
|
return $oksofar && $self->annotation eq $other->annotation; |
197
|
|
|
|
|
|
|
} else { |
198
|
0
|
|
|
|
|
|
return $oksofar; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
10
|
|
|
10
|
|
95
|
no Moose; |
|
10
|
|
|
|
|
25
|
|
|
10
|
|
|
|
|
62
|
|
203
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; |