1 package Text::Tradition::Collation::Relationship;
4 use Moose::Util::TypeConstraints;
6 enum 'RelationshipType' => qw( spelling orthographic grammatical lexical
7 collated repetition transposition punctuation );
9 enum 'RelationshipScope' => qw( local document global );
11 no Moose::Util::TypeConstraints;
15 Text::Tradition::Collation::Relationship - represents a syntactic or semantic
16 relationship between two readings
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
29 Creates a new relationship. Usually called via $collation->add_relationship.
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
41 =item * displayform - (Optional) The reading that should be displayed if the
42 related nodes are treated as one.
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.
49 =item * annotation - (Optional) A freeform note to attach to the relationship.
51 =item * alters_meaning - Indicate whether, in context, the related words cause
52 the text to have different meanings. Possible values are 0 (no), 1 (slightly),
55 =item * non_correctable - (Optional) True if the reading would not have been
56 corrected independently.
58 =item * non_independent - (Optional) True if the variant is unlikely to have
59 occurred independently in unrelated witnesses.
73 =head2 non_correctable
75 =head2 non_independent
77 See the option descriptions above.
83 isa => 'RelationshipType',
99 has 'displayform' => (
102 predicate => 'has_displayform',
107 isa => 'RelationshipScope',
111 has 'annotation' => (
114 predicate => 'has_annotation',
117 has 'alters_meaning' => (
123 has 'non_correctable' => (
128 has 'non_independent' => (
133 around 'alters_meaning' => sub {
137 if( $_[0] eq 'no' ) {
138 return $self->$orig( 0 );
139 } elsif( $_[0] eq 'slightly' ) {
140 return $self->$orig( 1 );
141 } elsif( $_[0] eq 'yes' ) {
142 return $self->$orig( 2 );
145 return $self->$orig( @_ );
148 # A read-only meta-Boolean attribute.
152 Returns true if the relationship type is one that requires that its readings
153 occupy the same place in the collation.
159 return $self->type !~ /^(repetition|transposition)$/;
164 Returns true if the relationship scope is anything other than 'local'.
170 return $self->scope ne 'local';
174 __PACKAGE__->meta->make_immutable;