X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition%2FParser%2FBaseText.pm;h=96d54ff036058f6bb560737cd8edc29359ee6b71;hb=63778331994b16f1890a1d6aa1a1e0dbfad73a21;hp=e07cdec4f037aceb16d2648d20031bff2d95bb04;hpb=a2cf85dd89b882408436836441a51588d97ed443;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition/Parser/BaseText.pm b/lib/Text/Tradition/Parser/BaseText.pm index e07cdec..96d54ff 100644 --- a/lib/Text/Tradition/Parser/BaseText.pm +++ b/lib/Text/Tradition/Parser/BaseText.pm @@ -3,7 +3,9 @@ package Text::Tradition::Parser::BaseText; use strict; use warnings; use Module::Load; -use Text::Tradition::Parser::Util qw( collate_variants cmp_str check_for_repeated add_hash_entry ); +use TryCatch; +use Text::Tradition::Parser::Util qw( collate_variants cmp_str + check_for_repeated add_hash_entry ); =head1 NAME @@ -392,10 +394,20 @@ sub set_relationships { $r->id ne $labels{$r->text}->id ) { if( $type eq 'repetition' ) { # Repetition - $collation->add_relationship( $r, $labels{$r->text}, \%rel_options ); + try { + $collation->add_relationship( $r, $labels{$r->text}, \%rel_options ); + } catch( Text::Tradition::Error $e ) { + warn "Could not set repetition relationship $r -> " + . $labels{$r->text} . ": " . $e->message; + } } else { # Transposition - $r->set_identical( $labels{$r->text} ); + try { + $r->set_identical( $labels{$r->text} ); + } catch( Text::Tradition::Error $e ) { + warn "Could not set transposition relationship $r -> " + . $labels{$r->text} . ": " . $e->message; + } } } } @@ -413,8 +425,13 @@ sub set_relationships { $rel_options{'equal_rank'} = 1; if( @$lemma == @$var ) { foreach my $i ( 0 .. $#{$lemma} ) { - $collation->add_relationship( $var->[$i], $lemma->[$i], - \%rel_options ); + try { + $collation->add_relationship( $var->[$i], $lemma->[$i], + \%rel_options ); + } catch( Text::Tradition::Error $e ) { + warn "Could not set $type relationship " . $var->[$i] . " -> " + . $lemma->[$i] . ": " . $e->message; + } } } else { # An uneven many-to-many mapping. Skip for now. @@ -422,9 +439,9 @@ sub set_relationships { # my $lemseg = @$lemma > 1 ? $collation->add_segment( @$lemma ) : $lemma->[0]; # my $varseg = @$var > 1 ? $collation->add_segment( @$var ) : $var->[0]; # $collation->add_relationship( $varseg, $lemseg, \%rel_options ); - if( @$lemma == 1 && @$var == 1 ) { - $collation->add_relationship( $lemma->[0], $var->[0], \%rel_options ); - } + # if( @$lemma == 1 && @$var == 1 ) { + # $collation->add_relationship( $lemma->[0], $var->[0], \%rel_options ); + # } } } elsif( $type !~ /^(add|om|lex)$/i ) { warn "Unrecognized type $type";