sub as_graphml {
my( $self ) = @_;
-
+ $self->calculate_ranks unless $self->_graphcalc_done;
+
# Some namespaces
my $graphml_ns = 'http://graphml.graphdrawing.org/xmlns';
my $xsi_ns = 'http://www.w3.org/2001/XMLSchema-instance';
relationship => 'string', # ID/label for a relationship
extra => 'boolean', # Path key
scope => 'string', # Relationship key
+ annotation => 'string', # Relationship key
non_correctable => 'boolean', # Relationship key
non_independent => 'boolean', # Relationship key
);
}
}
}
-
-=head2 remove_collations
-
-Another convenience method for parsing. Removes all 'collation' relationships
-that were defined in order to get the reading ranks to be correct.
-
-=begin testing
-
-use Text::Tradition;
-
-my $cxfile = 't/data/Collatex-16.xml';
-my $t = Text::Tradition->new(
- 'name' => 'inline',
- 'input' => 'CollateX',
- 'file' => $cxfile,
- );
-my $c = $t->collation;
-
-isnt( $c->reading('n23')->rank, $c->reading('n9')->rank, "Rank skew exists" );
-$c->add_relationship( 'n23', 'n9', { 'type' => 'collated', 'scope' => 'local' } );
-is( scalar $c->relationships, 4, "Found all expected relationships" );
-$c->remove_collations;
-is( scalar $c->relationships, 3, "Collated relationships now gone" );
-is( $c->reading('n23')->rank, $c->reading('n9')->rank, "Aligned ranks were preserved" );
-
-=end testing
-
-=cut
-
-sub remove_collations {
- my $self = shift;
- foreach my $reledge ( $self->relationships ) {
- my $relobj = $self->relations->get_relationship( $reledge );
- if( $relobj && $relobj->type eq 'collated' ) {
- $self->relations->delete_relationship( $reledge );
- }
- }
-}
=head2 calculate_common_readings
my $target = delete $options->{'orig_b'};
my $rel = $self->get_relationship( $source, $target );
if( $rel ) {
- if( $rel->type ne $options->{'type'} ) {
+ if( $rel->type eq 'collated' ) {
+ # Always replace a 'collated' relationship with a more descriptive
+ # one, if asked.
+ $self->del_relationship( $source, $target );
+ } elsif( $rel->type ne $options->{'type'} ) {
throw( "Another relationship of type " . $rel->type
. " already exists between $source and $target" );
} else {
my $rel_obj = $self->get_relationship( @$e );
_add_graphml_data( $edge_el, $edge_keys->{'relationship'}, $rel_obj->type );
_add_graphml_data( $edge_el, $edge_keys->{'scope'}, $rel_obj->scope );
+ _add_graphml_data( $edge_el, $edge_keys->{'annotation'}, $rel_obj->annotation );
_add_graphml_data( $edge_el, $edge_keys->{'non_correctable'},
$rel_obj->non_correctable ) if $rel_obj->noncorr_set;
_add_graphml_data( $edge_el, $edge_keys->{'non_independent'},
);
my $c = $t->collation;
-isnt( $c->reading('n23')->rank, $c->reading('n9')->rank, "Rank skew exists" );
-$c->add_relationship( 'n23', 'n9', { 'type' => 'collated', 'scope' => 'local' } );
-is( scalar $c->relationships, 4, "Found all expected relationships" );
-$c->remove_collations;
-is( scalar $c->relationships, 3, "Collated relationships now gone" );
-is( $c->reading('n23')->rank, $c->reading('n9')->rank, "Aligned ranks were preserved" );
-}
-
-
-
-# =begin testing
-{
-use Text::Tradition;
-
-my $cxfile = 't/data/Collatex-16.xml';
-my $t = Text::Tradition->new(
- 'name' => 'inline',
- 'input' => 'CollateX',
- 'file' => $cxfile,
- );
-my $c = $t->collation;
-
my @common = $c->calculate_common_readings();
is( scalar @common, 8, "Found correct number of common readings" );
my @marked = sort $c->common_readings();