X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=script%2Fsvg_from_csv.pl;h=9b72e7a81ab635c2fd142bc6b814d5cf36b9ef5b;hb=cca4f996c756a6989b0c38aa13f974b31f3da54a;hp=c469bbe1b3ab1c14e25788db23b3fcf6e5bf744d;hpb=dd3b58b01da8319a3e3cc31e8f99a25be101cf05;p=scpubgit%2Fstemmatology.git diff --git a/script/svg_from_csv.pl b/script/svg_from_csv.pl index c469bbe..9b72e7a 100644 --- a/script/svg_from_csv.pl +++ b/script/svg_from_csv.pl @@ -1,14 +1,41 @@ -#!/usr/bin/env perl +#!/usr/bin/perl use lib 'lib'; use strict; use warnings; -use Text::Tradition::Graph; +use Text::Tradition; -my $collation_graph = Text::Tradition::Graph->new( - 'CSV' => $ARGV[0], - 'base' => $ARGV[1], - ); +# First: read the base. Make a graph, but also note which +# nodes represent line beginnings. -print $collation_graph->as_svg(); -print STDERR "Done\n"; +my $tradition = Text::Tradition->new( + 'CSV' => $ARGV[0], + 'base' => $ARGV[1], + 'linear' => 0, + ); + + +print $tradition->collation->as_svg(); +print STDERR "DONE\n"; +__END__ +my $rows = 0; +my $matrix = []; +foreach my $pos ( $collation_graph->{'positions'}->all ) { + my @p_nodes = $collation_graph->{'positions'}->nodes_at_position( $pos ); + $rows = scalar @p_nodes + if $rows < scalar @p_nodes; + push( @$matrix, \@p_nodes ); +} +print "A table\n"; +foreach my $i ( 0 .. $rows-1 ) { + print "\t\n"; + foreach my $col( @$matrix ) { + my $str = ''; + if( $col->[$i] ) { + $str = $collation_graph->node( $col->[$i] )->label; + } + printf( "\t\t\n", $str ); + } + print "\t\n"; +} +print "
%s
\n";