line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Tradition::Collation::RelationshipType; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
70
|
use Moose; |
|
10
|
|
|
|
|
28
|
|
|
10
|
|
|
|
|
85
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Text::Tradition::Collation::RelationshipType - describes a syntactic, |
8
|
|
|
|
|
|
|
semantic, etc. relationship that can be made between two readings |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Text::Tradition is a library for representation and analysis of collated |
13
|
|
|
|
|
|
|
texts, particularly medieval ones. A relationship connects two readings |
14
|
|
|
|
|
|
|
within a collation, usually when they appear in the same place in different |
15
|
|
|
|
|
|
|
texts. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head2 new |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Creates a new relationship type. Usually called via |
22
|
|
|
|
|
|
|
$collation->register_relationship_type. Options include: |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=over 4 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item * name - (Required string) The name of this relationship type. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item * bindlevel - (Required int) How tightly the relationship binds. A |
29
|
|
|
|
|
|
|
lower number indicates a closer binding. If A and B are related at |
30
|
|
|
|
|
|
|
bindlevel 0, and B and C at bindlevel 1, it implies that A and C have the |
31
|
|
|
|
|
|
|
same relationship as B and C do. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item * is_weak - (Default false) Whether this relationship should be |
34
|
|
|
|
|
|
|
replaced silently by a stronger type if requested. This is used primarily |
35
|
|
|
|
|
|
|
for the internal 'collated' relationship, only to be used by parsers. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item * is_colocation - (Default true) Whether this relationship implies |
38
|
|
|
|
|
|
|
that the readings in question have parallel locations. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item * is_transitive - (Default 1) Whether this relationship type is |
41
|
|
|
|
|
|
|
transitive - that is, if A is related to B and C this way, is B necessarily |
42
|
|
|
|
|
|
|
related to C? |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item * is_generalizable - (Default is_colocation) Whether this |
45
|
|
|
|
|
|
|
relationship can have a non-local scope. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * use_regular - (Default is_generalizable) Whether, when a |
48
|
|
|
|
|
|
|
relationship has a non-local scope, the search should be made on the |
49
|
|
|
|
|
|
|
regularized form of the reading. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=back |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 ACCESSORS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 name |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 bindlevel |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 is_weak |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 is_colocation |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 is_transitive |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 is_generalizable |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 use_regular |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
See the option descriptions above. All attributes are read-only. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has 'name' => ( |
74
|
|
|
|
|
|
|
is => 'ro', |
75
|
|
|
|
|
|
|
isa => 'Str', |
76
|
|
|
|
|
|
|
required => 1, |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has 'bindlevel' => ( |
80
|
|
|
|
|
|
|
is => 'ro', |
81
|
|
|
|
|
|
|
isa => 'Int', |
82
|
|
|
|
|
|
|
required => 1 |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has 'description' => ( |
86
|
|
|
|
|
|
|
is => 'ro', |
87
|
|
|
|
|
|
|
isa => 'Str', |
88
|
|
|
|
|
|
|
required => 1 |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has 'is_weak' => ( |
92
|
|
|
|
|
|
|
is => 'ro', |
93
|
|
|
|
|
|
|
isa => 'Bool', |
94
|
|
|
|
|
|
|
default => 0, |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
has 'is_colocation' => ( |
98
|
|
|
|
|
|
|
is => 'ro', |
99
|
|
|
|
|
|
|
isa => 'Bool', |
100
|
|
|
|
|
|
|
default => 1 |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
has 'is_transitive' => ( |
104
|
|
|
|
|
|
|
is => 'ro', |
105
|
|
|
|
|
|
|
isa => 'Bool', |
106
|
|
|
|
|
|
|
default => 1 |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
has 'is_generalizable' => ( |
110
|
|
|
|
|
|
|
is => 'ro', |
111
|
|
|
|
|
|
|
isa => 'Bool', |
112
|
|
|
|
|
|
|
lazy => 1, |
113
|
|
|
|
|
|
|
default => sub { $_[0]->is_colocation } |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# TODO I really want to make some configurable coderefs... |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
has 'use_regular' => ( |
119
|
|
|
|
|
|
|
is => 'ro', |
120
|
|
|
|
|
|
|
isa => 'Bool', |
121
|
|
|
|
|
|
|
lazy => 1, |
122
|
|
|
|
|
|
|
default => sub { $_[0]->is_generalizable } |
123
|
|
|
|
|
|
|
); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 DEFAULTS |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This package provides the following set of relationships as default: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 orthographic: bindlevel => 0, use_regular => 0 |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
The readings are orthographic variants of each other (e.g. upper vs. lower case letters.) If the Morphology plugin is in use, orthographically related readings should regularize to the same string. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 spelling: bindlevel => 1 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
The readings are spelling variations of the same word(s), e.g. 'color' vs. 'colour'. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 punctuation: bindlevel => 2 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
The readings are both punctuation markers. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 grammatical: bindlevel => 2 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
The readings are morphological variants of the same root word, e.g. 'was' vs. 'were'. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 lexical: bindlevel => 2 |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The readings have the same morphological function but different root words, e.g. '[they] worked' vs. '[they] played'. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 uncertain: bindlevel => 50, is_transitive => 0, is_generalizable => 0 |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
The readings are (probably) related, but it is impossible to say for sure how. Useful for when one or both of the readings is itself uncertain. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 transposition: bindlevel => 50, is_colocation => 0 |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
The readings are the same (or perhaps close variants), but the position has shifted across witnesses. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 repetition: bindlevel => 50, is_colocation => 0, is_transitive => 0 |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
One of the readings is a repetition of the other, e.g. "pet the cat" vs. "pet the the cat". |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 other: bindlevel => 50, is_transitive => 0, is_generalizable => 0 |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
A catch-all relationship for cases not covered by the other relationship types. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head2 collated: bindlevel => 50, is_weak => 1, is_generalizable => 0 |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
For internal use only. Denotes a parallel pair of variant readings as detected by an automatic collator. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 METHODS |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 regularize( $reading ) |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Given a Reading object, return the regular form of the reading text that this |
174
|
|
|
|
|
|
|
relationship type expects. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# TODO Define extra validation conditions here when we can store coderefs |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
sub regularize { |
181
|
0
|
|
|
0
|
1
|
|
my( $self, $rdg ) = @_; |
182
|
0
|
0
|
0
|
|
|
|
if( $self->use_regular && $rdg->can('regularize') ) { |
183
|
0
|
|
|
|
|
|
return $rdg->regularize; |
184
|
|
|
|
|
|
|
} |
185
|
0
|
|
|
|
|
|
return $rdg->text; |
186
|
|
|
|
|
|
|
} |
187
|
10
|
|
|
10
|
|
66903
|
no Moose; |
|
10
|
|
|
|
|
28
|
|
|
10
|
|
|
|
|
50
|
|
188
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
1; |