working with new base text merge routine, up to line 25
[scpubgit/stemmatology.git] / lib / Text / Tradition / Witness.pm
index f570365..145eba4 100644 (file)
@@ -32,25 +32,19 @@ has 'path' => (
     predicate => 'has_path',
     );        
 
-has 'post_correctione' => (
-    is => 'rw',
-    isa => 'Str',
-    predicate => 'has_post_correctione',
-    );
-
 subtype 'Correction',
     as 'ArrayRef',
     where { @{$_} == 3 &&
-           $_->[0]->isa( 'Int' ) &&
-           $_->[1]->isa( 'Int' ) &&
-           $_->[2]->isa( 'ArrayRef[Text::Tradition::Collation::Reading]' );
+           find_type_constraint('Int')->check( $_->[0] ) &&
+           find_type_constraint('Int')->check( $_->[1] ) &&
+           find_type_constraint('ArrayRef[Text::Tradition::Collation::Reading]')->check( $_->[2] );
     },
     message { 'Correction must be a tuple of [offset, length, list]' };
 
-has 'corrections' => (
-    is => 'ro',
+has 'ante_corr' => (
+    is => 'rw',
     isa => 'ArrayRef[Correction]',
-    default => sub { [] },
+    predicate => 'has_ante_corr',
     );
     
 
@@ -85,20 +79,14 @@ around text => sub {
     $self->$orig( @_ );
 };
 
-sub add_correction {
-    my( $self, $offset, $length, @replacement ) = @_;
-    # Rely on Moose for type checking of the arguments
-    push( @{$self->corrections}, [ $offset, $length, \@replacement ] );
-}
-
-sub corrected_path {
+sub uncorrected_path {
     my $self = shift;
 
     my @new_path;
     push( @new_path, @{$self->path} );
     my $drift = 0;
-    foreach my $correction ( @{$self->corrections} ) {
-       my( $offset, $length, $items ) = @$correction;
+    foreach my $change ( @{$self->ante_corr} ) {
+       my( $offset, $length, $items ) = @$change;
        my $realoffset = $offset + $drift;
        splice( @new_path, $realoffset, $length, @$items );
        $drift += @$items - $length;