From: Tara L Andrews Date: Fri, 10 Feb 2012 21:40:26 +0000 (+0100) Subject: add relationship deletion functionality X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ee801e17d007001be15c1b17d4942ffb234aa14f;p=scpubgit%2Fstemmatology.git add relationship deletion functionality --- diff --git a/lib/Text/Tradition/Collation.pm b/lib/Text/Tradition/Collation.pm index 85d09bf..cc197ff 100644 --- a/lib/Text/Tradition/Collation.pm +++ b/lib/Text/Tradition/Collation.pm @@ -27,6 +27,7 @@ has 'relations' => ( handles => { relationships => 'relationships', related_readings => 'related_readings', + del_relationship => 'del_relationship', }, writer => '_set_relations', ); diff --git a/lib/Text/Tradition/Collation/RelationshipStore.pm b/lib/Text/Tradition/Collation/RelationshipStore.pm index 93c4699..9e9b718 100644 --- a/lib/Text/Tradition/Collation/RelationshipStore.pm +++ b/lib/Text/Tradition/Collation/RelationshipStore.pm @@ -23,9 +23,38 @@ general) between readings. =begin testing use Text::Tradition; +use TryCatch; use_ok( 'Text::Tradition::Collation::RelationshipStore' ); +# Add some relationships, and delete them + +my $cxfile = 't/data/Collatex-16.xml'; +my $t = Text::Tradition->new( + 'name' => 'inline', + 'input' => 'CollateX', + 'file' => $cxfile, + ); +my $c = $t->collation; + +my @v1 = $c->add_relationship( 'n21', 'n22', { 'type' => 'meaning' } ); +is( scalar @v1, 1, "Added a single relationship" ); +is( $v1[0]->[0], 'n21', "Got correct node 1" ); +is( $v1[0]->[1], 'n22', "Got correct node 2" ); +my @v2 = $c->add_relationship( 'n9', 'n23', + { 'type' => 'spelling', 'scope' => 'global' } ); +is( scalar @v2, 2, "Added a global relationship with two instances" ); +@v1 = $c->del_relationship( 'n22', 'n21' ); +is( scalar @v1, 1, "Deleted first relationship" ); +@v2 = $c->del_relationship( 'n8', 'n13' ); +is( scalar @v2, 2, "Deleted second global relationship" ); +try { + my @v3 = $c->del_relationship( 'n1', 'n2' ); + ok( 0, "Should have errored on non-existent relationship" ); +} catch( Text::Tradition::Error $e ) { + like( $e->message, qr/No relationship defined/, "Attempt to delete non-existent relationship errored" ); +} + =end testing =head1 METHODS @@ -230,6 +259,31 @@ sub add_relationship { return @pairs_set; } +=head2 del_relationship( $source, $target ) + +Removes the relationship between the given readings. If the relationship is +non-local, removes the relationship everywhere in the graph. + +=cut + +sub del_relationship { + my( $self, $source, $target ) = @_; + my $rel = $self->get_relationship( $source, $target ); + throw( "No relationship defined between $source and $target" ) unless $rel; + my @vectors = ( [ $source, $target ] ); + $self->_remove_relationship( $source, $target ); + if( $rel->nonlocal ) { + # Remove the relationship wherever it occurs. + my @rel_edges = grep { $self->get_relationship( @$_ ) == $rel } + $self->relationships; + foreach my $re ( @rel_edges ) { + $self->_remove_relationship( @$re ); + push( @vectors, $re ); + } + } + return @vectors; +} + =head2 relationship_valid( $source, $target, $type ) Checks whether a relationship of type $type may exist between the readings given diff --git a/t/data/john.xml b/t/data/john.xml new file mode 100644 index 0000000..75452a6 --- /dev/null +++ b/t/data/john.xml @@ -0,0 +1,7619 @@ + + + + + + + + + + + + + + + + + + + + + + 3.0 + , + base text + 1 + (a.c.) + + #END# + 1 + #END# + 68 + + + #START# + 1 + #START# + 0 + + + Λ̣έγει + 1,1 + 1 + + + Λεγει + 1,2 + 1 + + + ν̣ηθια + 1,3 + 1 + + + λεγει + 1,4 + 1 + + + λέγει + 1,5 + 1 + + + Και + 10,1 + 9 + + + Καὶ + 10,2 + 9 + + + και + 10,3 + 9 + + + τουΤο + 11,1 + 10 + + + τουτ̣ο + 11,2 + 10 + + + τουτο + 11,3 + 10 + + + Τουτο + 11,4 + 10 + + + τοῦτο + 11,5 + 10 + + + ειπον + 12,1 + 11 + + + εἰπὼν + 12,2 + 11 + + + ειπων + 12,3 + 11 + + + ειπω¯ + 12,4 + 11 + + + ειπ̣ῶν + 12,5 + 11 + + + παλιν + 13,1 + 12 + + + Παλιν + 13,2 + 12 + + + πάλιν + 13,3 + 12 + + + παλην + 13,4 + 12 + + + παλι¯ + 13,5 + 12 + + + παΛιν + 13,6 + 12 + + + εξήλθεν + 14,1 + 12 + + + εξηλθεν + 14,2 + 13 + + + εξηλθε¯ + 14,3 + 13 + + + εξηλθε + 14,4 + 13 + + + ἐξῆλθεν + 14,5 + 13 + + + εξηλθ̣εν + 14,6 + 13 + + + Προϲ + 15,1 + 14 + + + προϲ + 15,2 + 14 + + + πρὸς + 15,3 + 14 + + + τοὺς + 16,1 + 15 + + + τουϲ + 16,2 + 15 + + + τουϲ̣ + 16,3 + 15 + + + ιουδαιουϲ + 17,1 + 16 + + + Ἰουδαίους + 17,2 + 16 + + + ϊουδαιουϲ + 17,3 + 16 + + + ϊουδαιουϲʼ + 17,4 + 16 + + + καὶ + 18,1 + 17 + + + Και + 18,2 + 17 + + + και + 18,3 + 17 + + + λεγει̣ + 19,1 + 18 + + + λεγει + 19,2 + 18 + + + λέγει + 19,3 + 18 + + + ου̣ν + 2,1 + 2 + + + αυτοιϲ + 20,1 + 19 + + + αὐτοῖς + 20,2 + 19 + + + εγω + 21,1 + 20 + + + ἐγὼ + 21,2 + 20 + + + εγῶ + 21,3 + 20 + + + ουδαιμιαν + 22,1 + 21 + + + ουδεμίαν + 22,2 + 21 + + + ου̣δεμιαν + 22,3 + 21 + + + οὐδεμίαν + 22,4 + 21 + + + ουδεμιαν + 22,5 + 21 + + + ευριϲκω + 23,1 + 22 + + + ε̣υριϲκω + 23,2 + 22 + + + αιτιαν + 24,1 + 23 + + + ευ + 25,1 + 24 + + + ριϲκω + 26,1 + 25 + + + ευ̣ριϲκω + 26,2 + 22 + + + ευριϲκω + 26,3 + 24 + + + εὑρίσκω + 26,4 + 22 + + + ευρηϲκω + 26,5 + 24 + + + ἐν + 27,1 + 23 + + + ε¯ + 27,2 + 25 + + + εν + 27,3 + 25 + + + αυτῶ + 28,1 + 26 + + + αυτω + 28,2 + 26 + + + αὐτῷ + 28,3 + 24 + + + αιτια¯ + 29,1 + 27 + + + αυτῶ + 3,1 + 2 + + + αυτω + 3,2 + 3 + + + αὐτῷ + 3,3 + 2 + + + αυΤω + 3,4 + 2 + + + αι̣τια̣ν̣ + 30,1 + 23 + + + αἰτίαν + 30,2 + 25 + + + αιτίαν + 30,3 + 27 + + + αιτιαν + 30,4 + 27 + + + έϲτιν + 31,1 + 28 + + + εϲτιν + 31,2 + 28 + + + ἔστιν + 32,1 + 26 + + + εν + 32,2 + 24 + + + αυτωʼ + 33,1 + 25 + + + εϲτι + 34,1 + 27 + + + εϲτ̣ι̣¯ + 34,2 + 26 + + + εϲτι¯ + 34,3 + 27 + + + δε + 35,1 + 29 + + + δὲ + 35,2 + 27 + + + ϲυνηθεια + 36,1 + 30 + + + ϲυνιθεια + 36,2 + 30 + + + Συνηθεια + 36,3 + 30 + + + ϲυνηθια + 36,4 + 30 + + + συνήθεια + 36,5 + 28 + + + ϲυνειθεια + 36,6 + 30 + + + ϲυνήθεια + 36,7 + 30 + + + υ + 37,1 + 31 + + + ὑμῖν + 38,1 + 32 + + + ϊ̣ν̣α̣ + 39,1 + 33 + + + ἵνα + 39,2 + 33 + + + ιΝα + 39,3 + 33 + + + ϊνα + 39,4 + 33 + + + Ινα + 39,5 + 33 + + + απολεϲ̣θαι + 39,6 + 33 + + + ινα + 39,7 + 33 + + + ο + 4,1 + 4 + + + Ο + 4,2 + 4 + + + ὁ + 4,3 + 3 + + + ε̣ν̣α̣ + 40,1 + 34 + + + το + 40,2 + 34 + + + ενα + 40,3 + 34 + + + ἕνα + 40,4 + 34 + + + απολυω + 41,1 + 35 + + + υμι¯ + 41,2 + 35 + + + υμειν + 41,3 + 35 + + + ἀπολύσω + 42,1 + 35 + + + απολ̀ύϲω + 42,2 + 35 + + + απολυϲω + 42,3 + 36 + + + υμι¯ + 43,1 + 37 + + + ϋμὶν + 43,2 + 36 + + + ὑμῖν + 43,3 + 36 + + + ϋμιν + 43,4 + 37 + + + υμιν + 43,5 + 37 + + + απολυϲω + 44,1 + 38 + + + ἐν + 45,1 + 37 + + + εν + 45,2 + 39 + + + το + 46,1 + 40 + + + τω + 46,2 + 40 + + + τῷ + 46,3 + 38 + + + πάϲχα + 47,1 + 41 + + + παϲ̣χα + 47,2 + 41 + + + πάσχα + 47,3 + 39 + + + παϲχα + 47,4 + 41 + + + βουλεϲθαι + 48,1 + 42 + + + βουλεϲθ + 48,2 + 42 + + + βουλεϲθ̣α̣ι̣ + 48,3 + 42 + + + βούλεσθε + 48,4 + 40 + + + βουΛεϲθαιουν + 48,5 + 42 + + + βουλεϲθε + 48,6 + 42 + + + βὸύλεϲθε + 48,7 + 42 + + + οὖν + 49,1 + 41 + + + ουν + 49,2 + 43 + + + ου¯ + 49,3 + 43 + + + πειλατοϲ + 5,1 + 5 + + + υμι¯ + 50,1 + 44 + + + υ + 50,2 + 44 + + + ϊνα + 50,3 + 44 + + + ινα + 50,4 + 44 + + + μιν + 51,1 + 45 + + + ἀπολύσω + 52,1 + 42 + + + απολ̀ύϲω + 52,2 + 43 + + + απολυϲω + 52,3 + 46 + + + ϋμὶν + 53,1 + 44 + + + ϋμϊν + 53,2 + 47 + + + ὑμῖν + 53,3 + 43 + + + ϋμιν + 53,4 + 47 + + + υμιν + 53,5 + 47 + + + απολυϲω + 54,1 + 48 + + + το¯ + 55,1 + 49 + + + τον + 55,2 + 49 + + + τὸν + 55,3 + 44 + + + βαϲιλέα + 56,1 + 50 + + + βαϲιλεα + 56,2 + 50 + + + βασιλέα + 56,3 + 45 + + + των + 57,1 + 51 + + + τον + 57,2 + 51 + + + τῶν + 57,3 + 46 + + + τω¯ + 57,4 + 51 + + + ιουδαιων + 58,1 + 52 + + + ιουδαι̣ω̣ν̣ + 58,2 + 52 + + + ϊουδαίων + 58,3 + 52 + + + ιουδαιω¯ + 58,4 + 52 + + + ϊουδαιων + 58,5 + 52 + + + Ἰουδαίων + 58,6 + 47 + + + εκρὰύγαϲαν + 59,1 + 53 + + + εκραυαϲαν + 59,2 + 53 + + + εκραυγαϲαν + 59,3 + 53 + + + ἐκραύγασαν + 59,4 + 48 + + + ε̣κ̣ραυγαϲαν + 59,5 + 53 + + + εκραυπαμανου + 59,6 + 53 + + + εκραυγαϲα¯ + 59,7 + 53 + + + ε̣κραυγαϲαν + 59,8 + 53 + + + εΚραυγαϲαν + 59,9 + 53 + + + πειλατοϲ + 6,1 + 5 + + + πιλατοϲ + 6,2 + 5 + + + πιλάτοϲ + 6,3 + 5 + + + Πιλᾶτος + 6,4 + 4 + + + ὃῦν + 60,1 + 54 + + + Ουν + 60,2 + 54 + + + οὖν + 60,3 + 49 + + + ουν + 60,4 + 54 + + + ου¯ + 60,5 + 54 + + + παλιν + 61,1 + 55 + + + παλ̣ιν̣ + 61,2 + 55 + + + Παλιν + 61,3 + 55 + + + παντ̣ε̣ϲ̣ + 61,4 + 55 + + + πάλιν + 61,5 + 55 + + + παλι¯ + 61,6 + 55 + + + παντεϲ + 61,7 + 55 + + + παντεϲ + 62,1 + 56 + + + λέγοντες + 63,1 + 56 + + + λεγονΤεϲ + 63,2 + 57 + + + λεγοντεϲ + 63,3 + 57 + + + λεγο¯τεϲ + 63,4 + 57 + + + πα̣ντεϲ + 64,1 + 58 + + + μη + 64,2 + 58 + + + μὴ + 64,3 + 57 + + + τοῦτον + 65,1 + 58 + + + τουτον̣ + 65,2 + 59 + + + τουτον + 65,3 + 59 + + + τουτο¯ + 65,4 + 59 + + + αλλα + 66,1 + 60 + + + αλ + 66,2 + 60 + + + ἀλλὰ + 66,3 + 59 + + + αλλα̣ + 66,4 + 60 + + + τον + 67,1 + 61 + + + τὸν + 67,2 + 60 + + + βαραββα¯ + 68,1 + 62 + + + βαρραββαν + 68,2 + 62 + + + Βαραββᾶν + 68,3 + 61 + + + βαραββαν + 68,4 + 62 + + + ἦν + 69,1 + 62 + + + ην + 69,2 + 63 + + + Τι + 7,1 + 6 + + + τιϲ + 7,2 + 6 + + + τι + 7,3 + 6 + + + τί + 7,4 + 6 + + + δε + 70,1 + 64 + + + δὲ + 70,2 + 63 + + + ο + 71,1 + 65 + + + ὁ + 71,2 + 64 + + + Βαραββᾶς + 72,1 + 65 + + + βαρραβαϲ + 72,2 + 66 + + + βαραβαϲ + 72,3 + 66 + + + βαραββαϲ + 72,4 + 66 + + + β̣αραββαϲ + 72,5 + 65 + + + ληϲτηϲ + 73,1 + 67 + + + ληϲτ̣η̣ϲ̣ʼ + 73,2 + 66 + + + λῃστής + 73,3 + 66 + + + ἐστιν + 8,1 + 7 + + + εϲτιν + 8,2 + 7 + + + ε̣ϲ̣τιν + 8,3 + 7 + + + εϲτι¯ + 8,4 + 7 + + + εϲτιν̣ + 8,5 + 7 + + + αληθεια + 9,1 + 8 + + + αληθια + 9,2 + 8 + + + αλήθεια + 9,3 + 8 + + + αληθηα + 9,4 + 8 + + + ἀλήθεια + 9,5 + 8 + + + base + path + + + w11 + path + + + w2 + path + + + w211 + path + + + w37 + path + + + w38 + path + + + w44 + path + + + w54 + path + + + P66 + path + + + w1 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w39 + path + + + w41 + path + + + w45 + path + + + w7 + path + + + P60 + path + + + w290 + path + + + w290 + path + + + w11 + path + + + w2 + path + + + w211 + path + + + w37 + path + + + w38 + path + + + w44 + path + + + w54 + path + + + P60 + path + + + w30 + path + + + w45 + path + + + w1 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w39 + path + + + w41 + path + + + w7 + path + + + P66 + path + + + base + path + + + w11 + path + + + w37 + path + + + w44 + path + + + w54 + path + + + base + path + + + w211 + path + + + w30 + path + + + P66 + path + + + w1 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w38 + path + + + w41 + path + + + w45 + path + + + w7 + path + + + w290 + path + + + w39 + path + + + w211 + path + + + w30 + path + + + w290 + path + + + w19 + path + + + w34 + path + + + w7 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w32 + path + + + w33 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w39 + path + + + base + path + + + w211 + path + + + w7 + path + + + base + path + + + w41 + path + + + w38 + path + + + w2 + path + + + w30 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w32 + path + + + w33 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w34 + path + + + w19 + path + + + w290 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w32 + path + + + w33 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w19 + path + + + w3 + path + + + P66 + path + + + w34 + path + + + w41 + path + + + base + path + + + w38 + path + + + w30 + path + + + w2 + path + + + w290 + path + + + w1 + path + + + w11 + path + + + w17 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w13 + path + + + w19 + path + + + w3 + path + + + w34 + path + + + base + path + + + P66 + path + + + w13 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w290 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + base + path + + + base + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w1 + path + + + w290 + path + + + w3 + path + + + P66 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w37 + path + + + w38 + path + + + base + path + + + w1 + path + + + w290 + path + + + w3 + path + + + P66 + path + + + base + path + + + w37 + path + + + w38 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + P66 + path + + + w290 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w290 + path + + + base + path + + + P66 + path + + + w290 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + base + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w54 + path + + + w7 + path + + + w45 + path + + + base + path + + + w290 + path + + + w45 + path + + + w290 + path + + + P66 + path + + + base + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w30 + path + + + w32 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w54 + path + + + w7 + path + + + w19 + path + + + w211 + path + + + w3 + path + + + w33 + path + + + w211 + path + + + w3 + path + + + w33 + path + + + w290 + path + + + w54 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w30 + path + + + w32 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w7 + path + + + w211 + path + + + w17 + path + + + w54 + path + + + w54 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w28 + path + + + w30 + path + + + w32 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w7 + path + + + w22 + path + + + base + path + + + w17 + path + + + base + path + + + w22 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w7 + path + + + w290 + path + + + w290 + path + + + w30 + path + + + w34 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w32 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w7 + path + + + w3 + path + + + w33 + path + + + w19 + path + + + base + path + + + w19 + path + + + w290 + path + + + w28 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w3 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w54 + path + + + w7 + path + + + P66 + path + + + base + path + + + w30 + path + + + w45 + path + + + P66 + path + + + base + path + + + w290 + path + + + w3 + path + + + w33 + path + + + w290 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w32 + path + + + w33 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + base + path + + + P66 + path + + + P66 + path + + + w34 + path + + + P66 + path + + + w30 + path + + + w1 + path + + + w290 + path + + + w211 + path + + + w54 + path + + + w11 + path + + + w28 + path + + + w34 + path + + + w7 + path + + + P66 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + base + path + + + w30 + path + + + P66 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w3 + path + + + w32 + path + + + w33 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w211 + path + + + w11 + path + + + w28 + path + + + w34 + path + + + w7 + path + + + w1 + path + + + base + path + + + w54 + path + + + w290 + path + + + w30 + path + + + w54 + path + + + w1 + path + + + w290 + path + + + w3 + path + + + w11 + path + + + w13 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w45 + path + + + w7 + path + + + w211 + path + + + P66 + path + + + w17 + path + + + w44 + path + + + P60 + path + + + base + path + + + P66 + path + + + base + path + + + w17 + path + + + w1 + path + + + w3 + path + + + w290 + path + + + w44 + path + + + P60 + path + + + w11 + path + + + w13 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w45 + path + + + w7 + path + + + w290 + path + + + w2 + path + + + w211 + path + + + w3 + path + + + w32 + path + + + w38 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w21 + path + + + w22 + path + + + w30 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w28 + path + + + base + path + + + P66 + path + + + P60 + path + + + w21 + path + + + w32 + path + + + w54 + path + + + w22 + path + + + w1 + path + + + w17 + path + + + w19 + path + + + w3 + path + + + w30 + path + + + w33 + path + + + w37 + path + + + w41 + path + + + w44 + path + + + w11 + path + + + w13 + path + + + w2 + path + + + w28 + path + + + w34 + path + + + w36 + path + + + w38 + path + + + w39 + path + + + w45 + path + + + w7 + path + + + w290 + path + + + base + path + + + w32 + path + + + w21 + path + + + w22 + path + + + base + path + + + w290 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w44 + path + + + P66 + path + + + w17 + path + + + w19 + path + + + w30 + path + + + w33 + path + + + w37 + path + + + w41 + path + + + w1 + path + + + w3 + path + + + w41 + path + + + w290 + path + + + base + path + + + w3 + path + + + w54 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w2 + path + + + w28 + path + + + w34 + path + + + w36 + path + + + w38 + path + + + w39 + path + + + w45 + path + + + w7 + path + + + P66 + path + + + w17 + path + + + w19 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w37 + path + + + w11 + path + + + w13 + path + + + w2 + path + + + w28 + path + + + w34 + path + + + w36 + path + + + w38 + path + + + w39 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + base + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w290 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w211 + path + + + w211 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + P66 + path + + + w290 + path + + + base + path + + + w290 + path + + + P66 + path + + + base + path + + + w2 + path + + + w22 + path + + + w32 + path + + + w37 + path + + + w38 + path + + + w45 + path + + + P60 + path + + + w19 + path + + + w7 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w21 + path + + + w211 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w54 + path + + + w2 + path + + + w22 + path + + + w32 + path + + + w37 + path + + + w38 + path + + + w45 + path + + + w19 + path + + + P60 + path + + + base + path + + + w7 + path + + + w30 + path + + + w44 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w21 + path + + + w211 + path + + + w28 + path + + + w3 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w39 + path + + + w41 + path + + + w54 + path + + + w290 + path + + + base + path + + + w45 + path + + + w17 + path + + + w32 + path + + + w41 + path + + + w54 + path + + + w1 + path + + + P60 + path + + + P66 + path + + + w2 + path + + + w211 + path + + + w22 + path + + + w3 + path + + + w33 + path + + + w38 + path + + + w13 + path + + + w21 + path + + + w28 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w11 + path + + + w19 + path + + + w44 + path + + + w30 + path + + + P66 + path + + + w211 + path + + + w3 + path + + + w32 + path + + + w38 + path + + + w11 + path + + + w45 + path + + + w1 + path + + + w17 + path + + + w30 + path + + + w32 + path + + + w41 + path + + + w54 + path + + + w45 + path + + + base + path + + + w290 + path + + + w11 + path + + + w38 + path + + + w45 + path + + + P60 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w211 + path + + + w22 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w41 + path + + + w44 + path + + + w1 + path + + + w3 + path + + + w54 + path + + + P66 + path + + + w290 + path + + + P66 + path + + + base + path + + + w1 + path + + + w3 + path + + + w54 + path + + + w22 + path + + + w33 + path + + + w13 + path + + + w21 + path + + + w28 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w7 + path + + + P60 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w211 + path + + + w30 + path + + + w32 + path + + + w41 + path + + + w44 + path + + + w13 + path + + + w21 + path + + + w28 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w7 + path + + + w1 + path + + + w22 + path + + + w33 + path + + + w7 + path + + + w290 + path + + + P60 + path + + + P66 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + base + path + + + w290 + path + + + w19 + path + + + P60 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w38 + path + + + base + path + + + w1 + path + + + w3 + path + + + w54 + path + + + w13 + path + + + P60 + path + + + P66 + path + + + w11 + path + + + w17 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w7 + path + + + w290 + path + + + w38 + path + + + base + path + + + w19 + path + + + w37 + path + + + P66 + path + + + w45 + path + + + w11 + path + + + w17 + path + + + w2 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w7 + path + + + w19 + path + + + w21 + path + + + P60 + path + + + w290 + path + + + w13 + path + + + w1 + path + + + w3 + path + + + w54 + path + + + base + path + + + w290 + path + + + w19 + path + + + w21 + path + + + w11 + path + + + w39 + path + + + w54 + path + + + w13 + path + + + w17 + path + + + w211 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w38 + path + + + w41 + path + + + w44 + path + + + w7 + path + + + w2 + path + + + w22 + path + + + w28 + path + + + base + path + + + P66 + path + + + w37 + path + + + w1 + path + + + w3 + path + + + P60 + path + + + w45 + path + + + w2 + path + + + w37 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w30 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w290 + path + + + base + path + + + w290 + path + + + w39 + path + + + w54 + path + + + w11 + path + + + base + path + + + P60 + path + + + w1 + path + + + w13 + path + + + w19 + path + + + w21 + path + + + w211 + path + + + w3 + path + + + w32 + path + + + w33 + path + + + w38 + path + + + w45 + path + + + w7 + path + + + P66 + path + + + w17 + path + + + w30 + path + + + w41 + path + + + w44 + path + + + w36 + path + + + w34 + path + + + w22 + path + + + w2 + path + + + w1 + path + + + w19 + path + + + w3 + path + + + w32 + path + + + w33 + path + + + w45 + path + + + w13 + path + + + w21 + path + + + w211 + path + + + w28 + path + + + w38 + path + + + w39 + path + + + w54 + path + + + w7 + path + + + P60 + path + + + w2 + path + + + w34 + path + + + P66 + path + + + base + path + + + w290 + path + + + w36 + path + + + w11 + path + + + w17 + path + + + w13 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w28 + path + + + w30 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w54 + path + + + w7 + path + + + w22 + path + + + base + path + + + w17 + path + + + P60 + path + + + w1 + path + + + w13 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w11 + path + + + w22 + path + + + w290 + path + + + w290 + path + + + w22 + path + + + w54 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w7 + path + + + P60 + path + + + base + path + + + base + path + + + P60 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w7 + path + + + P66 + path + + + w22 + path + + + w54 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w211 + path + + + P60 + path + + + base + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w39 + path + + + w41 + path + + + w38 + path + + + P66 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + base + path + + + w1 + path + + + w11 + path + + + w39 + path + + + w41 + path + + + w38 + path + + + base + path + + + P66 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + base + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w37 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w21 + path + + + w211 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + P66 + path + + + w22 + path + + + w38 + path + + + w2 + path + + + base + path + + + w290 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + base + path + + + w38 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w34 + path + + + base + path + + + base + path + + + w38 + path + + + w34 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + P66 + path + + + w1 + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w21 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + P66 + path + + + base + path + + + base + path + + + w11 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w211 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w37 + path + + + w39 + path + + + w41 + path + + + w44 + path + + + w45 + path + + + w54 + path + + + w7 + path + + + w21 + path + + + w290 + path + + + P66 + path + + + w1 + path + + + w22 + path + + + w38 + path + + + w2 + path + + + w11 + path + + + w37 + path + + + w44 + path + + + w54 + path + + + w1 + path + + + w13 + path + + + w17 + path + + + w19 + path + + + w2 + path + + + w211 + path + + + w22 + path + + + w28 + path + + + w3 + path + + + w30 + path + + + w32 + path + + + w33 + path + + + w34 + path + + + w36 + path + + + w38 + path + + + w39 + path + + + w41 + path + + + w45 + path + + + w7 + path + + + P66 + path + + + w290 + path + + + w21 + path + + + base + path + + + diff --git a/t/text_tradition_collation_relationshipstore.t b/t/text_tradition_collation_relationshipstore.t index f09e245..717c878 100644 --- a/t/text_tradition_collation_relationshipstore.t +++ b/t/text_tradition_collation_relationshipstore.t @@ -9,8 +9,37 @@ $| = 1; # =begin testing { use Text::Tradition; +use TryCatch; use_ok( 'Text::Tradition::Collation::RelationshipStore' ); + +# Add some relationships, and delete them + +my $cxfile = 't/data/Collatex-16.xml'; +my $t = Text::Tradition->new( + 'name' => 'inline', + 'input' => 'CollateX', + 'file' => $cxfile, + ); +my $c = $t->collation; + +my @v1 = $c->add_relationship( 'n21', 'n22', { 'type' => 'meaning' } ); +is( scalar @v1, 1, "Added a single relationship" ); +is( $v1[0]->[0], 'n21', "Got correct node 1" ); +is( $v1[0]->[1], 'n22', "Got correct node 2" ); +my @v2 = $c->add_relationship( 'n9', 'n23', + { 'type' => 'spelling', 'scope' => 'global' } ); +is( scalar @v2, 2, "Added a global relationship with two instances" ); +@v1 = $c->del_relationship( 'n22', 'n21' ); +is( scalar @v1, 1, "Deleted first relationship" ); +@v2 = $c->del_relationship( 'n8', 'n13' ); +is( scalar @v2, 2, "Deleted second global relationship" ); +try { + my @v3 = $c->del_relationship( 'n1', 'n2' ); + ok( 0, "Should have errored on non-existent relationship" ); +} catch( Text::Tradition::Error $e ) { + like( $e->message, qr/No relationship defined/, "Attempt to delete non-existent relationship errored" ); +} }