private void testGetSiblings(CTNode curr, CTNode[] children) { CTNode node; node = children[3].getLeftNearestSibling(CTLib.matchFo("TMP")); assertEquals(children[2], node); node = children[3].getLeftNearestSibling(CTLib.matchFo("LOC")); assertEquals(children[0], node); node = children[0].getRightNearestSibling(CTLib.matchFo("PRD")); assertEquals(children[3], node); }
private void testGetDescendants(CTNode curr, CTNode[] children) { CTNode node; node = curr.getFirstDescendant(CTLib.matchC("NP")); assertEquals(children[0], node); node = curr.getFirstDescendant(CTLib.matchC("NNP")); assertEquals(children[2].getFirstChild(), node); node = curr.getFirstLowestChainedDescendant(CTLib.matchC("PP")); assertEquals(children[3].getFirstChild(), node); }
private void testGetAncestors(CTNode curr, CTNode[] children, CTNode gChild) { CTNode node; node = children[0].getParent(); assertEquals(curr, node); node = gChild.getNearestAncestor(CTLib.matchF("TMP")); assertEquals(children[2], node); node = gChild.getNearestAncestor(CTLib.matchF("LOC")); assertEquals(curr, node); node = gChild.getNearestAncestor(CTLib.matchF("BNF")); assertEquals(null, node); node = gChild.getHighestChainedAncestor(CTLib.matchF("LOC")); assertEquals(null, node); node = gChild.getHighestChainedAncestor(CTLib.matchF("TMP")); assertEquals(children[2], node); node = gChild.getHighestChainedAncestor(CTLib.matchFo("LOC", "TMP")); assertEquals(curr, node); node = children[1].getLowestCommonAncestor(gChild); assertEquals(curr, node); node = curr.getLowestCommonAncestor(gChild); assertEquals(curr, node); node = gChild.getLowestCommonAncestor(curr); assertEquals(curr, node); }
private void testGetChildren(CTNode curr, CTNode[] children) { Pattern p = PatternUtils.createClosedORPattern("PP", "CC"); List<CTNode> list; list = curr.getChildrenList(CTLib.matchC("NP")); assertEquals("[(NP-LOC null), (NP-TMP null)]", list.toString()); list = curr.getChildrenList(CTLib.matchCo("PP", "CC")); assertEquals("[(CC and), (PP-LOC-PRD null)]", list.toString()); list = curr.getChildrenList(CTLib.matchP(p)); assertEquals("[(CC and), (PP-LOC-PRD null)]", list.toString()); list = curr.getChildrenList(CTLib.matchFa("LOC", "PRD")); assertEquals("[(PP-LOC-PRD null)]", list.toString()); list = curr.getChildrenList(CTLib.matchFo("TMP", "PRD")); assertEquals("[(NP-TMP null), (PP-LOC-PRD null)]", list.toString()); list = curr.getChildrenList(CTLib.matchCFa("NP", "LOC", "PRD")); assertEquals("[]", list.toString()); list = curr.getChildrenList(CTLib.matchCFo("NP", "LOC", "PRD")); assertEquals("[(NP-LOC null)]", list.toString()); list = curr.getChildrenList(CTLib.matchPFa(p, "TMP", "PRD")); assertEquals("[]", list.toString()); list = curr.getChildrenList(CTLib.matchPFo(p, "TMP", "PRD")); assertEquals("[(PP-LOC-PRD null)]", list.toString()); assertEquals(null, curr.getChild(-1)); assertEquals(null, curr.getChild(4)); assertEquals(children[0], curr.getFirstChild()); assertEquals(children[3], curr.getLastChild()); }