we no longer use position; stop breaking relationship adding
[scpubgit/stemmatology.git] / lib / Text / Tradition / Collation / Relationship.pm
index 03f9b14..c2ad3ae 100644 (file)
@@ -10,13 +10,13 @@ use MooseX::NonMoose;
 
 extends 'Graph::Easy::Edge';
 
-enum 'RelationshipType' => qw( spelling orthographic grammatical repetition );
+enum 'RelationshipType' => qw( spelling orthographic grammatical repetition lexical );
 
 subtype 'RelationshipVector',
     => as 'ArrayRef',
     => where { @$_ == 2
-              && $_->[0]->isa( 'Text::Tradition::Collation::Reading' )
-              && $_->[1]->isa( 'Text::Tradition::Collation::Reading' )
+              && $_->[0]->isa( 'Graph::Easy::Node' )
+              && $_->[1]->isa( 'Graph::Easy::Node' )
             },
     message { 'Argument should be [ SourceReading, TargetReading ]' };
 
@@ -27,19 +27,19 @@ subtype 'RelationshipTokenVector',
 
 no Moose::Util::TypeConstraints;  ## see comment above
                   
-has 'sort' => (
+has 'type' => (
     is => 'rw',
     isa => 'RelationshipType',
     required => 1,
 );
 
-has 'orig_relation' => (
+has 'this_relation' => (
     is => 'rw',
     isa => 'RelationshipVector',
     required => 1,
 );
 
-has 'related_readings' => (
+has 'primary_relation' => (
     is => 'rw',
     isa => 'RelationshipTokenVector',
 );
@@ -50,14 +50,29 @@ has 'global' => (
     default => 0,
 );
 
+has 'non_correctable' => (
+    is => 'rw',
+    isa => 'Bool',
+    );
+
+has 'non_independent' => (
+    is => 'rw',
+    isa => 'Bool',
+    );
+    
+has 'equal_rank' => (
+    is => 'rw',
+    isa => 'Bool',
+    );
+
 sub FOREIGNBUILDARGS {
     my $class = shift;
     my %args = @_;
 
-    # Make the label match our 'sort' attribute.
+    # Make the label match our 'type' attribute.
     my @superclass_args;
-    if( exists $args{'sort'} ) {
-       push( @superclass_args, 'label', $args{'sort'} );
+    if( exists $args{'type'} ) {
+       push( @superclass_args, 'label', $args{'type'} );
     }
     return @superclass_args;
 }
@@ -67,14 +82,9 @@ sub BUILD {
 
     $self->set_attribute( 'class', 'relationship' );
 
-    my( $source, $target ) = @{$self->orig_relation};
-    if( $source->has_position && $target->has_position
-       && $source->position ne $target->position ) {
-       die "Cannot set relationship between readings in different positions";
-    }
-    unless( $self->related_readings ) {
-       $self->related_readings( [ $self->orig_relation->[0]->label,
-                                  $self->orig_relation->[1]->label ] );
+    unless( $self->primary_relation ) {
+       $self->primary_relation( [ $self->this_relation->[0]->label,
+                                  $self->this_relation->[1]->label ] );
     }
 }