@@ -84,6 +84,39 @@ public void readXMLAddEdgeIterate() {
84
84
assertEquals (newSg , expected );
85
85
}
86
86
87
+ /**
88
+ * Test that removing an edge given its endpoints and the dependency type will remove all matching edges
89
+ */
90
+ @ Test
91
+ public void readXMLRemoveEdgeIterate () {
92
+ String doc = String .join (newline ,
93
+ "<ssurgeon-pattern-list>" ,
94
+ " <ssurgeon-pattern>" ,
95
+ " <uid>38</uid>" ,
96
+ " <notes>This is a simple test of addEdge</notes>" ,
97
+ " <semgrex>" + XMLUtils .escapeXML ("{}=a1 > {}=a2" ) + "</semgrex>" ,
98
+ " <edit-list>removeEdge -gov a1 -dep a2 -reln dep</edit-list>" ,
99
+ " </ssurgeon-pattern>" ,
100
+ "</ssurgeon-pattern-list>" );
101
+ Ssurgeon inst = Ssurgeon .inst ();
102
+ List <SsurgeonPattern > patterns = inst .readFromString (doc );
103
+ assertEquals (patterns .size (), 1 );
104
+ SsurgeonPattern pattern = patterns .get (0 );
105
+
106
+ SemanticGraph sg = SemanticGraph .valueOf ("[A-0 obj> B-1 obj> C-2 nsubj> [D-3 obj> E-4]]" );
107
+ SemanticGraph newSg = pattern .iterate (sg );
108
+ SemanticGraph expected = SemanticGraph .valueOf ("[A-0 obj> B-1 obj> C-2 nsubj> [D-3 obj> E-4]]" );
109
+ assertEquals (newSg , sg );
110
+
111
+ sg = SemanticGraph .valueOf ("[A-0 obj> B-1 dep> B-1 obj> C-2 nsubj> [D-3 obj> E-4]]" );
112
+ newSg = pattern .iterate (sg );
113
+ assertEquals (newSg , expected );
114
+
115
+ sg = SemanticGraph .valueOf ("[A-0 obj> B-1 dep> B-1 obj> C-2 dep> C-2 nsubj> [D-3 obj> E-4 dep> E-4]]" );
116
+ newSg = pattern .iterate (sg );
117
+ assertEquals (newSg , expected );
118
+ }
119
+
87
120
/**
88
121
* Simple test of an Ssurgeon edit script. This instances a simple semantic graph,
89
122
* a semgrex pattern, and then the resulting actions over the named nodes in the
0 commit comments