add some final statistics; try to color anonymous nodes too
[scpubgit/stemmatology.git] / make_tradition.pl
old mode 100644 (file)
new mode 100755 (executable)
index 14acdef..41c575f
@@ -26,7 +26,7 @@ if( $help ) {
     help();
 }
 
-unless( $informat =~ /^(CSV|CTE|KUL|Self|TEI|CollateX)$/i ) {
+unless( $informat =~ /^(CSV|CTE|KUL|Self|TEI|CollateX|tab(ular)?)$/i ) {
     help( "Input format must be one of CollateX, CSV, CTE, Self, TEI" );
 }
 $informat = 'CollateX' if $informat =~ /^c(ollate)?x$/i;
@@ -34,6 +34,7 @@ $informat = 'KUL' if $informat =~ /^kul$/i;
 $informat = 'CTE' if $informat =~ /^cte$/i;
 $informat = 'Self' if $informat =~ /^self$/i;
 $informat = 'TEI' if $informat =~ /^tei$/i;
+$informat = 'Tabular' if $informat =~ /^tab$/i;
 
 unless( $outformat =~ /^(graphml|svg|dot|stemma|csv)$/ ) {
     help( "Output format must be one of graphml, svg, csv, stemma, or dot" );
@@ -44,19 +45,12 @@ if( $informat eq 'KUL' && !$inbase ) {
     help( "$informat input needs a base text" );
 }
 
-# CSV parsing requires a filename; XML parsing requires a string.
 my $input = $ARGV[0];
-unless( $informat eq 'KUL' || $informat eq 'CSV' ) {
-    my @lines;
-    open( INFILE, "$input" ) or die "Could not read $input";
-    @lines = <INFILE>;
-    close INFILE;
-    $input = join( '', @lines );
-}
 
 # First: read the base. Make a graph, but also note which
 # nodes represent line beginnings.
-my %args = ( $informat => $input,
+my %args = ( 'input' => $informat,
+             'file' => $input,
              'linear' => $linear );
 $args{'base'} = $inbase if $inbase;
 my $tradition = Text::Tradition->new( %args );
@@ -79,7 +73,7 @@ if( $HACK ) {
 if( $outformat eq 'stemma' ) {
     my $stemma = Text::Tradition::Stemma->new( 
         'collation' => $tradition->collation );
-    my( $result, $tree ) = $stemma->run_pars();
+    my( $result, $tree ) = $stemma->run_phylip_pars();
     if( $result ) {
         print $tree;
     } else {