* support and test deletion of a tradition
* support and test deletion of a relationship
-* support and test graphml output for relationships
$recalculate is passed (and is a true value), the method will return a
cached copy of the SVG after the first call to the method.
+=begin testing
+
+use Text::Tradition;
+
+my $READINGS = 311;
+my $PATHS = 361;
+
+my $datafile = 't/data/florilegium_tei_ps.xml';
+my $tradition = Text::Tradition->new( 'input' => 'TEI',
+ 'name' => 'test0',
+ 'file' => $datafile,
+ 'linear' => 1 );
+
+ok( $tradition, "Got a tradition object" );
+is( scalar $tradition->witnesses, 13, "Found all witnesses" );
+ok( $tradition->collation, "Tradition has a collation" );
+
+my $c = $tradition->collation;
+is( scalar $c->readings, $READINGS, "Collation has all readings" );
+is( scalar $c->paths, $PATHS, "Collation has all paths" );
+is( scalar $c->relationships, 0, "Collation has all relationships" );
+
+# Add a few relationships
+$c->add_relationship( 'w123', 'w125', { 'type' => 'collated' } );
+$c->add_relationship( 'w193', 'w196', { 'type' => 'collated' } );
+$c->add_relationship( 'w257', 'w262', { 'type' => 'transposition' } );
+
+# Now write it to GraphML and parse it again.
+
+my $graphml = $c->as_graphml;
+my $st = Text::Tradition->new( 'input' => 'Self', 'string' => $graphml );
+is( scalar $st->collation->readings, $READINGS, "Reparsed collation has all readings" );
+is( scalar $st->collation->paths, $PATHS, "Reparsed collation has all paths" );
+is( scalar $st->collation->relationships, 3, "Reparsed collation has new relationships" );
+
+=end testing
+
=cut
sub as_graphml {
my $key = $rdg->rank . "||" . $rdg->text;
if( exists $unique_rank_rdg{$key} ) {
# Combine!
- # print STDERR "Combining readings at same rank: $key\n";
+ # print STDERR "Combining readings at same rank: $key\n";
$self->merge_readings( $unique_rank_rdg{$key}, $rdg );
} else {
$unique_rank_rdg{$key} = $rdg;
# ID to match.
if( exists $args->{'is_lacuna'} && !exists $args->{'text'} ) {
- $args->{'text'} = sprintf( "#LACUNA_%s#", $args->{'id'} );
+ $args->{'text'} = '#LACUNA#';
} elsif( exists $args->{'is_start'} ) {
$args->{'id'} = '#START#'; # Change the ID to ensure we have only one
$args->{'text'} = '#START#';
is( ref( $t ), 'Text::Tradition', "Parsed parallel-segmentation TEI" );
if( $t ) {
- is( scalar $t->collation->readings, 319, "Collation has all readings" );
- is( scalar $t->collation->paths, 375, "Collation has all paths" );
+ is( scalar $t->collation->readings, 311, "Collation has all readings" );
+ is( scalar $t->collation->paths, 361, "Collation has all paths" );
}
=end testing
my $source = shift @uncorrected; # the start node
warn "Something weird!" unless $source eq $c->start;
foreach my $rdg ( @uncorrected ) {
- my $source_base = grep { $_ eq $sig } $c->reading_witnesses( $source );
- my $target_base = grep { $_ eq $sig } $c->reading_witnesses( $rdg );
- unless( $source_base && $target_base ) {
- # print STDERR sprintf( "Adding path %s from %s -> %s\n",
- # $sig.$c->ac_label, $source->id, $rdg->id );
- $c->add_path( $source, $rdg, $sig.$c->ac_label );
- }
- $source = $rdg;
+ unless( $c->has_path( $source, $rdg, $sig ) ) {
+ $c->add_path( $source, $rdg, $sig.$c->ac_label );
+ }
+ $source = $rdg;
}
+ warn "Something else weird!" unless $source eq $c->end;
# print STDERR "Adding a.c. version for witness $sig\n";
$tradition->witness( $sig )->is_layered( 1 );
}
ok( $tradition->collation, "Tradition has a collation" );
my $c = $tradition->collation;
-is( scalar $c->readings, 319, "Collation has all readings" );
-is( scalar $c->paths, 375, "Collation has all paths" );
+is( scalar $c->readings, 311, "Collation has all readings" );
+is( scalar $c->paths, 361, "Collation has all paths" );
is( scalar $c->relationships, 0, "Collation has all relationships" );
done_testing;
\ No newline at end of file
{
use Text::Tradition;
+my $READINGS = 311;
+my $PATHS = 361;
+
+my $datafile = 't/data/florilegium_tei_ps.xml';
+my $tradition = Text::Tradition->new( 'input' => 'TEI',
+ 'name' => 'test0',
+ 'file' => $datafile,
+ 'linear' => 1 );
+
+ok( $tradition, "Got a tradition object" );
+is( scalar $tradition->witnesses, 13, "Found all witnesses" );
+ok( $tradition->collation, "Tradition has a collation" );
+
+my $c = $tradition->collation;
+is( scalar $c->readings, $READINGS, "Collation has all readings" );
+is( scalar $c->paths, $PATHS, "Collation has all paths" );
+is( scalar $c->relationships, 0, "Collation has all relationships" );
+
+# Add a few relationships
+$c->add_relationship( 'w123', 'w125', { 'type' => 'collated' } );
+$c->add_relationship( 'w193', 'w196', { 'type' => 'collated' } );
+$c->add_relationship( 'w257', 'w262', { 'type' => 'transposition' } );
+
+# Now write it to GraphML and parse it again.
+
+my $graphml = $c->as_graphml;
+my $st = Text::Tradition->new( 'input' => 'Self', 'string' => $graphml );
+is( scalar $st->collation->readings, $READINGS, "Reparsed collation has all readings" );
+is( scalar $st->collation->paths, $PATHS, "Reparsed collation has all paths" );
+is( scalar $st->collation->relationships, 3, "Reparsed collation has new relationships" );
+}
+
+
+
+# =begin testing
+{
+use Text::Tradition;
+
my $cxfile = 't/data/Collatex-16.xml';
my $t = Text::Tradition->new(
'name' => 'inline',
is( ref( $t ), 'Text::Tradition', "Parsed parallel-segmentation TEI" );
if( $t ) {
- is( scalar $t->collation->readings, 319, "Collation has all readings" );
- is( scalar $t->collation->paths, 375, "Collation has all paths" );
+ is( scalar $t->collation->readings, 311, "Collation has all readings" );
+ is( scalar $t->collation->paths, 361, "Collation has all paths" );
}
}