X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition%2FParser%2FTabular.pm;h=723c0aac76140e71b14e20edc8b2c6b2539c9e48;hb=0655d30ce9cda59f3f25091aa4bb50e2b28c65a5;hp=40cf668574ab444bfa3fbed2e950bcc3c63236f4;hpb=bba696c66813d8225e17a1bf0b5c443473e6da9c;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition/Parser/Tabular.pm b/lib/Text/Tradition/Parser/Tabular.pm index 40cf668..723c0aa 100644 --- a/lib/Text/Tradition/Parser/Tabular.pm +++ b/lib/Text/Tradition/Parser/Tabular.pm @@ -177,14 +177,13 @@ sub parse { # add them to the witness paths. foreach my $idx ( 1 .. $#{$alignment_table} ) { my $row = $alignment_table->[$idx]; - my $nodes = make_nodes( $c, $row, $idx ); + my $nodes = _make_nodes( $c, $row, $idx ); foreach my $w ( 0 .. $#{$row} ) { # push the appropriate node onto the appropriate witness path my $word = $row->[$w]; if( $word ) { my $reading = $nodes->{$word}; my $wit = $witnesses[$w]; - $DB::single = 1 unless $wit; push( @{$wit->path}, $reading ); } # else skip it for empty readings. } @@ -244,11 +243,13 @@ sub parse { } } -sub make_nodes { +sub _make_nodes { my( $collation, $row, $index ) = @_; my %unique; + my $commonctr = 0; # Holds the number of unique readings + gaps, ex. lacunae. foreach my $w ( @$row ) { $unique{$w} = 1 if $w; + $commonctr +=1 unless ( $w && $w eq '#LACUNA#' ); } my $ctr = 1; foreach my $w ( keys %unique ) { @@ -257,7 +258,11 @@ sub make_nodes { 'rank' => $index, 'text' => $w, }; - $rargs->{'is_lacuna'} = 1 if $w eq '#LACUNA#'; + if( $w eq '#LACUNA#' ) { + $rargs->{'is_lacuna'} = 1; + } elsif( $commonctr == 1 ) { + $rargs->{'is_common'} = 1; + } my $r = $collation->add_reading( $rargs ); $unique{$w} = $r; $ctr++;