From: Tara L Andrews Date: Thu, 1 Mar 2012 14:48:28 +0000 (+0100) Subject: deal with global relationships X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fdfa59a7bbe8db11eae700f02c1cb0bc0a312454;p=scpubgit%2Fstemmatology.git deal with global relationships --- diff --git a/lib/Text/Tradition/Parser/Self.pm b/lib/Text/Tradition/Parser/Self.pm index ca58c33..e3d6c00 100644 --- a/lib/Text/Tradition/Parser/Self.pm +++ b/lib/Text/Tradition/Parser/Self.pm @@ -120,11 +120,11 @@ if( $t ) { my( $IDKEY, $TOKENKEY, $TRANSPOS_KEY, $RANK_KEY, $START_KEY, $END_KEY, $LACUNA_KEY, $COMMON_KEY, $SOURCE_KEY, $TARGET_KEY, $WITNESS_KEY, $EXTRA_KEY, $RELATIONSHIP_KEY, - $SCOPE_KEY, $CORRECT_KEY, $INDEP_KEY ) + $SCOPE_KEY, $ANNOTATION_KEY, $CORRECT_KEY, $INDEP_KEY ) = qw/ id text identical rank is_start is_end is_lacuna is_common source target witness extra relationship - scope non_correctable non_independent /; + scope annotation non_correctable non_independent /; sub parse { my( $tradition, $opts ) = @_; @@ -208,12 +208,23 @@ sub parse { 'type' => $e->{$RELATIONSHIP_KEY}, 'scope' => $e->{$SCOPE_KEY}, }; + $relationship_opts->{'annotation'} = $e->{$ANNOTATION_KEY} + if exists $e->{$ANNOTATION_KEY}; $relationship_opts->{'non_correctable'} = $e->{$CORRECT_KEY} if exists $e->{$CORRECT_KEY}; $relationship_opts->{'non_independent'} = $e->{$INDEP_KEY} if exists $e->{$INDEP_KEY}; + # TODO unless relationship is scoped and that scoped relationship exists... + my $rel_exists; + if( $relationship_opts->{'scope'} ne 'local' ) { + my $relobj = $collation->get_relationship( $from->{$IDKEY}, $to->{$IDKEY} ); + if( $relobj && $relobj->{'scope'} eq $relationship_opts->{'scope'} + && $relobj->{'type'} eq $relationship_opts->{'type'} ) { + $rel_exists = 1; + } + } $collation->add_relationship( $from->{$IDKEY}, $to->{$IDKEY}, - $relationship_opts ); + $relationship_opts ) unless $rel_exists; } # Save the text for each witness so that we can ensure consistency