From: Tara L Andrews Date: Tue, 26 Jun 2012 03:29:35 +0000 (+0200) Subject: restore meta readings to equiv graph X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cecbe56d2d40d98548a5d2a155fbf847ce0e7bbc;p=scpubgit%2Fstemmatology.git restore meta readings to equiv graph --- diff --git a/lib/Text/Tradition/Collation.pm b/lib/Text/Tradition/Collation.pm index 0f6e657..ad7e7e3 100644 --- a/lib/Text/Tradition/Collation.pm +++ b/lib/Text/Tradition/Collation.pm @@ -299,10 +299,7 @@ sub add_reading { $self->_add_reading( $reading->id => $reading ); # Once the reading has been added, put it in both graphs. $self->sequence->add_vertex( $reading->id ); - # All meta readings save 'start' and 'end' get disregarded for relationships. - unless( $reading->is_nonrel ) { - $self->relations->add_reading( $reading->id ); - } + $self->relations->add_reading( $reading->id ); return $reading; }; @@ -311,19 +308,17 @@ around del_reading => sub { my $self = shift; my $arg = shift; - unless( ref( $arg ) eq 'Text::Tradition::Collation::Reading' ) { - $arg = $self->reading( $arg ) + if( ref( $arg ) eq 'Text::Tradition::Collation::Reading' ) { + $arg = $arg->id; } - my $argid = $arg->id; # Remove the reading from the graphs. $self->_graphcalc_done(0); $self->_clear_cache; # Explicitly clear caches to GC the reading - $self->sequence->delete_vertex( $argid ); - $self->relations->delete_reading( $argid ) - unless $arg->is_nonrel; + $self->sequence->delete_vertex( $arg ); + $self->relations->delete_reading( $arg ); # Carry on. - $self->$orig( $argid ); + $self->$orig( $arg ); }; =begin testing @@ -404,8 +399,7 @@ sub merge_readings { @wits{keys %$fwits} = values %$fwits; $self->sequence->set_edge_attributes( @vector, \%wits ); } - $self->relations->merge_readings( $kept, $deleted, $combine ) - unless $mergemeta; + $self->relations->merge_readings( $kept, $deleted, $combine ); # Do the deletion deed. if( $combine ) { @@ -446,7 +440,7 @@ sub add_path { # We only need the IDs for adding paths to the graph, not the reading # objects themselves. - my( $source, $target, $wit ) = $self->_objectify_args( @_ ); + my( $source, $target, $wit ) = $self->_stringify_args( @_ ); $self->_graphcalc_done(0); # Connect the readings @@ -1544,17 +1538,7 @@ sub calculate_ranks { # Transfer our rankings from the topological graph to the real one. foreach my $r ( $self->readings ) { - if( $r->is_nonrel ) { - # These are not in the equivalence graph. Grab the rank of the highest - # predecessor + 1. - my @preds = $self->sequence->predecessors( $r ); - my $mrank = 0; - map { my $rk = $node_ranks->{$self->equivalence( $_ )} + 1; - $mrank = $rk > $mrank ? $rk : $mrank; } - $self->sequence->predecessors( $r ); - throw( "All predecessors of $r unranked!" ) unless $mrank; - $r->rank( $mrank ); - } elsif( defined $node_ranks->{$self->equivalence( $r->id )} ) { + if( defined $node_ranks->{$self->equivalence( $r->id )} ) { $r->rank( $node_ranks->{$self->equivalence( $r->id )} ); } else { # Die. Find the last rank we calculated. @@ -1613,7 +1597,7 @@ sub flatten_ranks { next; } # Combine! - print STDERR "Combining readings at same rank: $key\n"; + #print STDERR "Combining readings at same rank: $key\n"; $changed = 1; $self->merge_readings( $unique_rank_rdg{$key}, $rdg ); # TODO see if this now makes a common point. diff --git a/lib/Text/Tradition/Collation/Reading.pm b/lib/Text/Tradition/Collation/Reading.pm index d6dc701..4a022b5 100644 --- a/lib/Text/Tradition/Collation/Reading.pm +++ b/lib/Text/Tradition/Collation/Reading.pm @@ -265,17 +265,6 @@ sub is_meta { return $self->is_start || $self->is_end || $self->is_lacuna || $self->is_ph; } -=head2 is_nonrel - -Similar to is_meta, but returns false for the start and end readings. - -=cut - -sub is_nonrel { - my $self = shift; - return $self->is_lacuna || $self->is_ph; -} - =head1 Convenience methods =head2 related_readings diff --git a/lib/Text/Tradition/Collation/RelationshipStore.pm b/lib/Text/Tradition/Collation/RelationshipStore.pm index d0c4c00..aeb8b7f 100644 --- a/lib/Text/Tradition/Collation/RelationshipStore.pm +++ b/lib/Text/Tradition/Collation/RelationshipStore.pm @@ -806,7 +806,6 @@ sub add_equivalence_edge { my( $self, $source, $target ) = @_; my $seq = $self->equivalence( $source ); my $teq = $self->equivalence( $target ); - return unless $seq && $teq; $self->equivalence_graph->add_edge( $seq, $teq ); }