fix change detection bug
[scpubgit/stemmatology.git] / lib / Text / Tradition / Parser / CollateX.pm
index d3a6dc5..7191f7e 100644 (file)
@@ -59,13 +59,14 @@ my $t = Text::Tradition->new(
 is( ref( $t ), 'Text::Tradition', "Parsed our own GraphML" );
 if( $t ) {
     is( scalar $t->collation->readings, 26, "Collation has all readings" );
-    is( scalar $t->collation->paths, 49, "Collation has all paths" );
+    is( scalar $t->collation->paths, 32, "Collation has all paths" );
     is( scalar $t->witnesses, 3, "Collation has all witnesses" );
     
     # Check an 'identical' node
     my $transposed = $t->collation->reading( 'n15' );
-    ok( $transposed->has_primary, "Reading links to transposed primary" );
-    is( $transposed->primary->name, 'n17', "Correct transposition link" );
+    my @related = $transposed->related_readings;
+    is( scalar @related, 1, "Reading links to transposed version" );
+    is( $related[0]->id, 'n17', "Correct transposition link" );
 }
 
 =end testing
@@ -78,7 +79,7 @@ my $TRANSKEY = 'identical';
 
 sub parse {
     my( $tradition, $opts ) = @_;
-    my $graph_data = graphml_parse( $opts );
+    my( $graph_data ) = graphml_parse( $opts );
     my $collation = $tradition->collation;
 
        # First add the readings to the graph.
@@ -91,7 +92,6 @@ sub parse {
         }
         my %node_data = %$n;
         my $gnode_args = { 
-               'collation' => $collation,
                'id' => delete $node_data{$IDKEY},
                'text' => delete $node_data{$CONTENTKEY},
         };
@@ -156,7 +156,11 @@ sub parse {
     }
     
     # Rank the readings.
-    $collation->calculate_ranks() if $collation->linear;
+    $collation->calculate_common_readings(); # will implicitly rank
+
+    # Save the text for each witness so that we can ensure consistency
+    # later on
+       $tradition->collation->text_from_paths();       
 }
     
 =head1 BUGS / TODO