change analysis graph calculation - closer but not correct yet.
[scpubgit/stemmatology.git] / make_tradition.pl
old mode 100644 (file)
new mode 100755 (executable)
index 6828e71..5f75f33
@@ -11,15 +11,16 @@ binmode STDERR, ":utf8";
 binmode STDOUT, ":utf8";
 eval { no warnings; binmode $DB::OUT, ":utf8"; };
 
-my( $informat, $inbase, $outformat, $help, $linear, $HACK ) 
-    = ( '', '', '', '', 1, 0 );
+my( $informat, $inbase, $outformat, $help, $linear, $name, $HACK ) 
+    = ( '', '', '', '', 1, 'Tradition', 0 );
 
-GetOptions( 'i|in=s'   => \$informat,
-            'b|base=s' => \$inbase,
-            'o|out=s'  => \$outformat,
+GetOptions( 'i|in=s'    => \$informat,
+            'b|base=s'  => \$inbase,
+            'o|out=s'   => \$outformat,
             'l|linear!' => \$linear,
-            'h|help' => \$help,
-            'hack' => \$HACK,
+            'n|name'    => \$name,
+            'h|help'    => \$help,
+            'hack'      => \$HACK,
     );
 
 if( $help ) {
@@ -45,22 +46,15 @@ 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";
-    binmode INFILE, ':utf8';
-    @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;
+$args{'name'} = $name if $name;
 my $tradition = Text::Tradition->new( %args );
 
 ### Custom hacking
@@ -81,7 +75,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 {