load extensions statically to avoid bad object wrapping interactions
[scpubgit/stemmatology.git] / analysis / lib / Text / Tradition / Analysis.pm
index 3b76ca1..f245b94 100644 (file)
@@ -16,7 +16,7 @@ use TryCatch;
 
 use vars qw/ @EXPORT_OK $VERSION /;
 @EXPORT_OK = qw/ run_analysis group_variants analyze_variant_location wit_stringify /;
-$VERSION = "1.0";
+$VERSION = "1.1";
 
 
 my $SOLVER_URL = 'http://byzantini.st/cgi-bin/graphcalc.cgi';
@@ -34,7 +34,6 @@ Text::Tradition::Analysis - functions for stemma analysis of a tradition
     'name' => 'this is a text',
     'input' => 'TEI',
     'file' => '/path/to/tei_parallel_seg_file.xml' );
-  $t->enable_stemmata;
   $t->add_stemma( 'dotfile' => $stemmafile );
 
   my $variant_data = run_analysis( $tradition );
@@ -87,7 +86,6 @@ my $datafile = 't/data/florilegium_tei_ps.xml';
 my $tradition = Text::Tradition->new( 'input' => 'TEI',
                                       'name' => 'test0',
                                       'file' => $datafile );
-$tradition->enable_stemmata;
 my $s = $tradition->add_stemma( 'dotfile' => 't/data/florilegium.dot' );
 is( ref( $s ), 'Text::Tradition::Stemma', "Added stemma to tradition" );
 
@@ -263,8 +261,10 @@ sub run_analysis {
                        if( $rdg ) {
                                $rdghash->{'text'} = $rdg->text . 
                                        ( $rdg->rank == $rank ? '' : ' [' . $rdg->rank . ']' );
-                               $rdghash->{'is_ungrammatical'} = $rdg->grammar_invalid;
-                               $rdghash->{'is_nonsense'} = $rdg->is_nonsense;
+                               if( $rdg->does( 'Text::Tradition::Morphology' ) ) {
+                                       $rdghash->{'is_ungrammatical'} = $rdg->grammar_invalid;
+                                       $rdghash->{'is_nonsense'} = $rdg->is_nonsense;
+                               }
                        }
                        # Remove lacunose witnesses from this reading's list now that the
                        # analysis is done 
@@ -810,8 +810,10 @@ sub _resolve_parent_relationships {
                        }
                        # Get the attributes of the parent object while we are here
                        $phash->{'text'} = $pobj->text if $pobj;
-                       $phash->{'is_nonsense'} = $pobj->is_nonsense;
-                       $phash->{'is_ungrammatical'} = $pobj->grammar_invalid;
+                       if( $pobj && $pobj->does('Text::Tradition::Morphology') ) {
+                               $phash->{'is_nonsense'} = $pobj->is_nonsense;
+                               $phash->{'is_ungrammatical'} = $pobj->grammar_invalid;
+                       }
                } elsif( $p eq '(omitted)' ) {
                        $phash->{relation} = { type => 'addition' };
                }