From: Eden Cardim Date: Tue, 31 Jul 2012 13:41:05 +0000 (-0300) Subject: fixing start/end nodes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2d808120de9b6e7a0be370f9e38ce2f1564e46f0;p=scpubgit%2Fstemmatology.git fixing start/end nodes --- diff --git a/lib/Text/Tradition/Collation.pm b/lib/Text/Tradition/Collation.pm index b246c7e..db0c8f1 100644 --- a/lib/Text/Tradition/Collation.pm +++ b/lib/Text/Tradition/Collation.pm @@ -52,6 +52,7 @@ has 'readings' => ( _add_reading => 'set', del_reading => 'delete', has_reading => 'exists', +# reading_keys => 'keys', readings => 'values', }, default => sub { {} }, diff --git a/lib/Text/Tradition/Parser/Self.pm b/lib/Text/Tradition/Parser/Self.pm index 432d8a3..64b4ee2 100644 --- a/lib/Text/Tradition/Parser/Self.pm +++ b/lib/Text/Tradition/Parser/Self.pm @@ -140,19 +140,20 @@ if( $newt ) { =end testing =cut - +use Data::Dump; sub parse { my( $tradition, $opts ) = @_; # Collation data is in the first graph; relationship-specific stuff # is in the second. my( $graph_data, $rel_data ) = graphml_parse( $opts ); - + my $collation = $tradition->collation; my %witnesses; # print STDERR "Setting graph globals\n"; $tradition->name( $graph_data->{'name'} ); + my $use_version; my $tmeta = $tradition->meta; my $cmeta = $collation->meta; @@ -173,8 +174,14 @@ sub parse { foreach my $n ( @{$graph_data->{'nodes'}} ) { # If it is the start or end node, we already have one, so # grab the rank and go. - next if( defined $n->{'is_start'} ); + if( defined $n->{'is_start'} ) { + warn Data::Dump::dump($n); + warn $collation->start->id; + $collation->start->rank($n->{'rank'}); + next; + } if( defined $n->{'is_end'} ) { + warn Data::Dump::dump($n); $collation->end->rank( $n->{'rank'} ); next; } @@ -184,8 +191,24 @@ sub parse { # Now add the edges. # print STDERR "Adding collation path edges\n"; foreach my $e ( @{$graph_data->{'edges'}} ) { - my $from = $collation->reading( $e->{'source'}->{'id'} ); - my $to = $collation->reading( $e->{'target'}->{'id'} ); + # warn Data::Dump::dump([$collation->reading_keys]); + warn $e->{source}{id}; + # warn $e->{target}{id}; + my($from, $to); + if($e->{source}{is_start}) { + $from = $collation->start; + } elsif($e->{source}{is_end}) { + $from = $collation->end; + } else { + $from = $collation->reading( $e->{'source'}->{'id'} ); + } + if($e->{target}{is_end}) { + $to = $collation->end; + } elsif($e->{target}{is_start}) { + $to = $collation->start; + } else { + $to = $collation->reading( $e->{'target'}->{'id'} ); + } warn "No witness label on path edge!" unless $e->{'witness'}; my $label = $e->{'witness'} . ( $e->{'extra'} ? $collation->ac_label : '' );