# Walk the paths for each witness in the graph, and return the nodes
# that the graph has in common. If $using_base is true, some
# different logic is needed.
+# NOTE This does not create paths; it merely finds common readings.
sub walk_witness_paths {
- my( $self, $end ) = @_;
+ my( $self ) = @_;
# For each witness, walk the path through the graph.
# Then we need to find the common nodes.
# TODO This method is going to fall down if we have a very gappy
my @common_readings;
foreach my $wit ( $self->tradition->witnesses ) {
my $curr_reading = $self->start;
- my @wit_path = $self->reading_sequence( $self->start, $end,
+ my @wit_path = $self->reading_sequence( $self->start, $self->end,
$wit->sigil );
$wit->path( \@wit_path );
}
-# An alternative to walk_witness_paths, for use when a collation is
-# constructed from a base text and an apparatus. We have the
-# sequences of readings and just need to add path edges.
+# For use when a collation is constructed from a base text and an apparatus.
+# We have the sequences of readings and just need to add path edges.
sub make_witness_paths {
my( $self ) = @_;
-
- my @common_readings;
foreach my $wit ( $self->tradition->witnesses ) {
print STDERR "Making path for " . $wit->sigil . "\n";
$self->make_witness_path( $wit );
- @common_readings = _find_common( \@common_readings, $wit->path );
- @common_readings = _find_common( \@common_readings, $wit->uncorrected_path );
}
- map { $_->make_common } @common_readings;
- return @common_readings;
}
sub make_witness_path {
}
}
-sub common_readings {
- my $self = shift;
- my @common = grep { $_->is_common } $self->readings();
- return sort { $a->position->cmp_with( $b->position ) } @common;
-}
-
sub calculate_ranks {
my $self = shift;
# Walk a version of the graph where every node linked by a relationship
$self->lemmata->{$cr->position->maxref} = $cr->name;
}
}
+
+sub common_readings {
+ my $self = shift;
+ my @common = grep { $_->is_common } $self->readings();
+ return sort { $a->position->cmp_with( $b->position ) } @common;
+}
=item B<lemma_readings>
}
}
- # Record for each witness its sequence of readings, and determine
- # the common nodes.
- my @common_nodes = $collation->walk_witness_paths( $end_node );
-
- # Now we have added the witnesses and their paths, so have also
- # implicitly marked the common nodes. Now we can calculate their
- # explicit positions.
- $collation->calculate_positions( @common_nodes );
+ # Now we have added the witnesses and their paths, so we can
+ # calculate their explicit positions.
+ # TODO CollateX does this, and we should just have it exported there.
+ $collation->calculate_positions();
}
=back
=cut
my $text = {}; # Hash of arrays, one per eventual witness we find.
-my @common_readings;
my $substitutions = {}; # Keep track of merged readings
my $app_anchors = {}; # Track apparatus references
my $app_ac = {}; # Save a.c. readings
foreach ( keys %$substitutions ) {
$tradition->collation->del_reading( $tradition->collation->reading( $_ ) );
}
- $tradition->collation->calculate_positions( @common_readings );
+ $tradition->collation->calculate_ranks();
}
sub _clean_sequence {
my $rdg = make_reading( $tradition->collation, $w );
push( @new_readings, $rdg );
unless( $in_var ) {
- push( @common_readings, $rdg );
$rdg->make_common;
}
foreach ( @cur_wits ) {
my $rdg = make_reading( $tradition->collation, $xn->textContent, $xml_id );
push( @new_readings, $rdg );
unless( $in_var ) {
- push( @common_readings, $rdg );
$rdg->make_common;
}
foreach( @cur_wits ) {