From: Tara L Andrews Date: Tue, 17 Apr 2012 11:21:16 +0000 (+0200) Subject: only collate a given sequence once X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f8b07f322b74f3069a49f4acd61fec80f5590e89;p=scpubgit%2Fstemmatology.git only collate a given sequence once --- diff --git a/lib/Text/Tradition/Parser/Util.pm b/lib/Text/Tradition/Parser/Util.pm index 9110655..8a17e7e 100644 --- a/lib/Text/Tradition/Parser/Util.pm +++ b/lib/Text/Tradition/Parser/Util.pm @@ -31,13 +31,22 @@ on the collation graph. sub collate_variants { my( $collation, @reading_sets ) = @_; + + # Make sure the reading sets are unique, but keep + # the lemma first. + my $lemma = shift @reading_sets; + my %unique_sets; + map { $unique_sets{$_} = $_ } @reading_sets; + delete $unique_sets{$lemma}; + my @sets = values %unique_sets; + unshift( @sets, $lemma ); # Two different ways to do this, depending on whether we want # transposed reading nodes to be merged into one (producing a # nonlinear, bidirectional graph) or not (producing a relatively # linear, unidirectional graph.) - return $collation->linear ? _collate_linearly( @_ ) - : _collate_nonlinearly( @_ ); + return $collation->linear ? _collate_linearly( $collation, @sets ) + : _collate_nonlinearly( $collation, @sets ); } sub _collate_linearly {