revert untested changes that were causing a segfault
[scpubgit/stemmatology.git] / script / make_tradition.pl
index 362758b..d1af8bf 100755 (executable)
@@ -4,17 +4,18 @@ use lib 'lib';
 use strict;
 use warnings;
 use Getopt::Long;
+use TryCatch;
 use Text::Tradition;
 use Text::Tradition::Directory;
-use Text::Tradition::StemmaUtil;
+use Text::Tradition::StemmaUtil qw/ character_input phylip_pars /;
 
 binmode STDERR, ":utf8";
 binmode STDOUT, ":utf8";
 eval { no warnings; binmode $DB::OUT, ":utf8"; };
 
-my( $informat, $inbase, $outformat, $help, $language, $name, $HACK, $sep, $stemmafile, 
+my( $informat, $inbase, $outformat, $help, $language, $name, $sep, $stemmafile, 
        $dsn, $dbuser, $dbpass ) 
-    = ( '', '', '', '', 1, 'Tradition', 0, "\t", '',
+    = ( '', '', '', '', 'Default', 'Tradition', "\t", '',
        "dbi:SQLite:dbname=stemmaweb/db/traditions.db", undef, undef );
 
 GetOptions( 'i|in=s'    => \$informat,
@@ -27,7 +28,6 @@ GetOptions( 'i|in=s'    => \$informat,
             'u|user=s'  => \$dbuser,
             'p|pass=s'  => \$dbpass,
             'sep=s'            => \$sep,
-            'hack'      => \$HACK,
             'dsn=s'            => \$dsn,
     );
 
@@ -76,24 +76,13 @@ if( $stemmafile ) {
        print STDERR "Saved stemma at $stemmafile\n" if $stemma;
 }
 
-### Custom hacking
-# Remove witnesses C, E, G in the Matthew text
-if( $HACK ) {
-       # Set the funny name while we're at it
-       my $oldname = $tradition->name;
-       $oldname =~ s/(\d)/ $1/;
-       my $newname = "\x{17d}amanakagrut\x{2bf}iwn " . ucfirst( $oldname );
-       $tradition->name( $newname );
-}
-
 # Now output what we have been asked to.
 if( $outformat eq 'stemma' ) {
-    my $cdata = character_input( $tradition->collation->make_alignment_table );
-    my( $result, $tree ) = phylip_pars( $cdata );
-    if( $result ) {
-        print $tree;
-    } else {
-        print STDERR "Bad result: $tree";
+    my $cdata = character_input( $tradition->collation->alignment_table );
+    try {
+       print phylip_pars( $cdata );
+    } catch( Text::Tradition::Error $e ) {
+        print STDERR "Bad result: " . $e->message;
     }
 } elsif( $outformat eq 'db' ) {
        my $extra_args = { 'create' => 1 };