X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition%2FAnalysis.pm;h=a9b3318ec012508753bd0ac114c9fb09cb642f21;hb=0a8f09a9a3eb1cb6861db715c2b6ed43e1e11402;hp=bdae9a50f755f254b9ab3ab56a368a35496bfa8a;hpb=3d79e2482917fea5ceb7c6b35d8935547b83934c;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition/Analysis.pm b/lib/Text/Tradition/Analysis.pm index bdae9a5..a9b3318 100644 --- a/lib/Text/Tradition/Analysis.pm +++ b/lib/Text/Tradition/Analysis.pm @@ -9,8 +9,9 @@ sub new { my( $class, $args ) = @_; my $self = {}; # Our object needs to have a stemma graph and a variant table. - my( $svg, $variants ) = run_analysis( $args->{'file'}, $args->{'stemmadot'} ); + my( $title, $svg, $variants ) = run_analysis( $args->{'file'}, $args->{'stemmadot'} ); $self->{'svg'} = $svg; + $self->{'title'} = $title; $self->{'variants'} = $variants; bless( $self, $class ); @@ -60,13 +61,19 @@ sub run_analysis { my $rdg_wits = {}; my $col_rdgs = shift @$all_wits_table; my $rank; + my $lacunose = []; foreach my $j ( 0 .. $#{$col_rdgs} ) { my $rdg = $col_rdgs->[$j]; my $rdg_text = '(omitted)'; # Initialize in case of empty reading if( $rdg ) { - $rdg_text = $rdg->is_lacuna ? undef : $rdg->text; # Don't count lacunae - # Get the rank from any real reading; they should be identical. - $rank = $rdg->rank unless $rank || $rdg->is_lacuna; + if( $rdg->is_lacuna ) { + $rdg_text = undef; # Don't count lacunae + push( @$lacunose, $col_wits->[$j] ); + } else { + $rdg_text = $rdg->text; + # Get the rank from any real reading; they should be identical. + $rank = $rdg->rank; + } } if( defined $rdg_text ) { # Initialize the witness array if we haven't got one yet @@ -98,11 +105,14 @@ sub run_analysis { # For all the groups with more than one member, collect the list of all # contiguous vertices needed to connect them. # TODO: deal with a.c. reading logic - my $sc = analyze_variant_location( $group_readings, $groups, $stemma->apsp ); - $variant_row->{'genealogical'} = keys %$sc ? 1 : undef; + my $conflict = analyze_variant_location( $group_readings, $groups, $stemma->apsp ); + $variant_row->{'genealogical'} = keys %$conflict ? undef : 1; foreach my $grp ( sort keys %$group_readings ) { my $rdg = $group_readings->{$grp}; - push( @{$variant_row->{'readings'}}, { 'text' => $rdg, 'group' => $grp } ); + my $in_conflict = exists $conflict->{$rdg}; + push( @{$variant_row->{'readings'}}, + { 'text' => $rdg, 'group' => $grp, 'conflict' => $in_conflict, + 'missing' => wit_stringify( $lacunose ) } ); } # Now run the same analysis given the calculated distance tree(s). @@ -124,7 +134,7 @@ sub run_analysis { $row->{'empty'} = $empty; } - return( $svg, $variants ); + return( $tradition->name, $svg, $variants ); } sub analyze_variant_location {