@@ -815,6 +815,47 @@ public void readXMLCheckSMNodes() {
815
815
assertEquals ("blue" , blueVertex .value ());
816
816
}
817
817
818
+
819
+ /**
820
+ * The AddDep should update the edge matches in the SemgrexMatcher.
821
+ * If that isn't done correctly, then moving the words first
822
+ * and then trying to update an edge that matched would not work
823
+ */
824
+ @ Test
825
+ public void readXMLCheckSMEdges () {
826
+ Ssurgeon inst = Ssurgeon .inst ();
827
+
828
+ // use "dep" as the dependency so as to be language-agnostic in this test
829
+ String add = String .join (newline ,
830
+ "<ssurgeon-pattern-list>" ,
831
+ " <ssurgeon-pattern>" ,
832
+ " <uid>38</uid>" ,
833
+ " <notes>Add a word before antennae using the position</notes>" ,
834
+ // have to bomb-proof the pattern
835
+ " <semgrex>" + XMLUtils .escapeXML ("{word:antennae}=antennae <obj=obj {} !> {word:blue}" ) + "</semgrex>" ,
836
+ " <edit-list>addDep -gov antennae -reln dep -word blue -position -antennae</edit-list>" ,
837
+ " <edit-list>relabelNamedEdge -edge obj -reln dep</edit-list>" ,
838
+ " </ssurgeon-pattern>" ,
839
+ "</ssurgeon-pattern-list>" );
840
+ List <SsurgeonPattern > patterns = inst .readFromString (add );
841
+ assertEquals (patterns .size (), 1 );
842
+ SsurgeonPattern addSsurgeon = patterns .get (0 );
843
+
844
+ SemanticGraph sg = SemanticGraph .valueOf ("[has-2 nsubj> Jennifer-1 obj> antennae-3]" );
845
+ IndexedWord blueVertex = sg .getNodeByIndexSafe (4 );
846
+ assertNull (blueVertex );
847
+ SemanticGraph newSG = addSsurgeon .iterate (sg );
848
+ // the edge update to change the name of the edge to "dep" should fire
849
+ SemanticGraph expected = SemanticGraph .valueOf ("[has-2 nsubj> Jennifer-1 dep> [antennae-4 dep> blue-3]]" );
850
+ assertEquals (expected , newSG );
851
+ // the Ssurgeon we just created should not put a tag on the word
852
+ // but it SHOULD put blue immediately before antennae
853
+ blueVertex = newSG .getNodeByIndexSafe (3 );
854
+ assertNotNull (blueVertex );
855
+ assertNull (blueVertex .tag ());
856
+ assertEquals ("blue" , blueVertex .value ());
857
+ }
858
+
818
859
/**
819
860
* Test that types which can't be converted from String
820
861
* are detected when making an AddDep
0 commit comments