stemmaweb bugfixes and style fixes; add 'punctuation' relationship type
[scpubgit/stemmatology.git] / lib / Text / Tradition / Collation / Relationship.pm
index e08fb3c..227bb7b 100644 (file)
@@ -3,8 +3,8 @@ package Text::Tradition::Collation::Relationship;
 use Moose;
 use Moose::Util::TypeConstraints;
 
-enum 'RelationshipType' => qw( spelling orthographic grammatical meaning lexical
-                                                          collated repetition transposition );
+enum 'RelationshipType' => qw( spelling orthographic grammatical lexical
+                                                          collated repetition transposition punctuation );
 
 enum 'RelationshipScope' => qw( local document global );
 
@@ -31,17 +31,32 @@ Options include:
 
 =over 4
 
-=item * type - Can be one of spelling, orthographic, grammatical, meaning, lexical, collated, repetition, transposition.  All but the last two are only valid relationships between readings that occur at the same point in the text.
+=item * type - Can be one of spelling, orthographic, grammatical, lexical, 
+collated, repetition, transposition.  All but the last two are only valid 
+relationships between readings that occur at the same point in the text. 
+The 'collated' relationship should only be used by parsers to align readings 
+in the graph when the input information would otherwise be lost, e.g. from
+an alignment table.
 
-=item * displayform - (Optional) The reading that should be displayed if the related nodes are treated as one.
+=item * displayform - (Optional) The reading that should be displayed if the 
+related nodes are treated as one.
 
-=item * scope - (Optional) A meta-attribute.  Can be one of 'local', 'document', or 'global'. Denotes whether the relationship between the two readings holds always, independent of context, either within this tradition or across all traditions.
+=item * scope - (Optional) A meta-attribute.  Can be one of 'local', 
+'document', or 'global'. Denotes whether the relationship between the two 
+readings holds always, independent of context, either within this tradition 
+or across all traditions.
 
-=item * anotation - (Optional) A freeform note to attach to the relationship.
+=item * annotation - (Optional) A freeform note to attach to the relationship.
 
-=item * non_correctable - (Optional) True if the reading would not have been corrected independently.
+=item * alters_meaning - Indicate whether, in context, the related words cause
+the text to have different meanings. Possible values are 0 (no), 1 (slightly),
+and >1 (yes).
 
-=item * non_independent - (Optional) True if the variant is unlikely to have occurred independently in unrelated witnesses.
+=item * non_correctable - (Optional) True if the reading would not have been 
+corrected independently.
+
+=item * non_independent - (Optional) True if the variant is unlikely to have 
+occurred independently in unrelated witnesses.
 
 =back
 
@@ -96,20 +111,40 @@ has 'scope' => (
 has 'annotation' => (
        is => 'ro',
        isa => 'Str',
+       predicate => 'has_annotation',
+       );
+       
+has 'alters_meaning' => (
+       is => 'rw',
+       isa => 'Int',
+       default => 0,
        );
 
 has 'non_correctable' => (
        is => 'ro',
        isa => 'Bool',
-       predicate => 'noncorr_set',
        );
 
 has 'non_independent' => (
        is => 'ro',
        isa => 'Bool',
-       predicate => 'nonind_set',
        );
        
+around 'alters_meaning' => sub {
+       my $orig = shift;
+       my $self = shift;
+       if( @_ ) {
+               if( $_[0] eq 'no' ) {
+                       return $self->$orig( 0 );
+               } elsif( $_[0] eq 'slightly' ) {
+                       return $self->$orig( 1 );
+               } elsif( $_[0] eq 'yes' ) {
+                       return $self->$orig( 2 );
+               } 
+       }
+       return $self->$orig( @_ );
+};             
+       
 # A read-only meta-Boolean attribute.
 
 =head2 colocated