1 package Text::Tradition::Collation::RelationshipType;
7 Text::Tradition::Collation::RelationshipType - describes a syntactic,
8 semantic, etc. relationship that can be made between two readings
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
21 Creates a new relationship type. Usually called via
22 $collation->register_relationship_type. Options include:
26 =item * name - (Required string) The name of this relationship type.
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.
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.
37 =item * is_colocation - (Default true) Whether this relationship implies
38 that the readings in question have parallel locations.
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
44 =item * is_generalizable - (Default is_colocation) Whether this
45 relationship can have a non-local scope.
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.
65 =head2 is_generalizable
69 See the option descriptions above. All attributes are read-only.
91 has 'is_colocation' => (
97 has 'is_transitive' => (
103 has 'is_generalizable' => (
107 default => sub { $_[0]->is_colocation }
110 # TODO I really want to make some configurable coderefs...
112 has 'use_regular' => (
116 default => sub { $_[0]->is_generalizable }
121 This package provides the following set of relationships as default:
123 =head2 orthographic: bindlevel => 0, use_regular => 0
125 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.
127 =head2 spelling: bindlevel => 1
129 The readings are spelling variations of the same word(s), e.g. 'color' vs. 'colour'.
131 =head2 punctuation: bindlevel => 2
133 The readings are both punctuation markers.
135 =head2 grammatical: bindlevel => 2
137 The readings are morphological variants of the same root word, e.g. 'was' vs. 'were'.
139 =head2 lexical: bindlevel => 2
141 The readings have the same morphological function but different root words, e.g. '[they] worked' vs. '[they] played'.
143 =head2 uncertain: bindlevel => 50, is_transitive => 0, is_generalizable => 0
145 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.
147 =head2 transposition: bindlevel => 50, is_colocation => 0
149 The readings are the same (or perhaps close variants), but the position has shifted across witnesses.
151 =head2 repetition: bindlevel => 50, is_colocation => 0, is_transitive => 0
153 One of the readings is a repetition of the other, e.g. "pet the cat" vs. "pet the the cat".
155 =head2 other: bindlevel => 50, is_transitive => 0, is_generalizable => 0
157 A catch-all relationship for cases not covered by the other relationship types.
159 =head2 collated: bindlevel => 50, is_weak => 1, is_generalizable => 0
161 For internal use only. Denotes a parallel pair of variant readings as detected by an automatic collator.
165 =head2 regularize( $reading )
167 Given a Reading object, return the regular form of the reading text that this
168 relationship type expects.
172 # TODO Define extra validation conditions here when we can store coderefs
175 my( $self, $rdg ) = @_;
176 if( $self->use_regular && $rdg->can('regularize') ) {
177 return $rdg->regularize;
182 __PACKAGE__->meta->make_immutable;