public static TreebankNode nextX(TreebankNode curX){ TreebankNode nextX = curX.getParent(); // Y = curX; while(!(nextX.getNodeType().equals("NP") || nextX.getNodeType().equals("S"))){ // Y = nextX; nextX = nextX.getParent(); if(nextX == null) break; } return nextX; }
public static TreebankNode nextX(TreebankNode curX){ TreebankNode nextX = curX.getParent(); // Y = curX; while(!(nextX.getNodeType().equals("NP") || nextX.getNodeType().equals("S"))){ // Y = nextX; nextX = nextX.getParent(); if(nextX == null) break; } return nextX; }
private static boolean isBe (TreebankNode n) { String phCat = n.getNodeType(); String txt = n.getCoveredText(); if ((phCat.equals("VB") || phCat.equals("VBZ") || phCat.equals("VBD") || phCat.equals("VBN")) && (txt.equalsIgnoreCase("is") || txt.equalsIgnoreCase("was") || txt.equalsIgnoreCase("been") || txt.equalsIgnoreCase("be"))) return true; return false; }
private static boolean isBe (TreebankNode n) { String phCat = n.getNodeType(); String txt = n.getCoveredText(); if ((phCat.equals("VB") || phCat.equals("VBZ") || phCat.equals("VBD") || phCat.equals("VBN")) && (txt.equalsIgnoreCase("is") || txt.equalsIgnoreCase("was") || txt.equalsIgnoreCase("been") || txt.equalsIgnoreCase("be"))) return true; return false; }
private static TreebankNode findP (TreebankNode n, String phraseTag, int startingChild) { FSArray c = n.getChildren(); int i = startingChild; while (i < c.size()) { TreebankNode tn = (TreebankNode) c.get(i++); if (tn.getNodeType().equals(phraseTag) || tn.getNodeType().startsWith(phraseTag+"-")) return tn; } return null; }
private static TreebankNode findP (TreebankNode n, String phraseTag, int startingChild) { FSArray c = n.getChildren(); int i = startingChild; while (i < c.size()) { TreebankNode tn = (TreebankNode) c.get(i++); if (tn.getNodeType().equals(phraseTag) || tn.getNodeType().startsWith(phraseTag+"-")) return tn; } return null; }
private static String calcNPunderVP(TreebankNode n){ if(n != null && n.getParent() != null && n.getParent().getNodeType().equals("VP")){ return "Y"; } return "N"; }
private static String calcNPunderS(TreebankNode n){ if(n != null && n.getParent() != null && n.getParent().getNodeType().equals("S")){ return "Y"; } return "N"; }
private static String calcNPunderPP(TreebankNode n){ if(n != null && n.getParent() != null && n.getParent().getNodeType().equals("PP")){ return "Y"; } return "N"; }
private static String calcNPunderPP(TreebankNode n){ if(n != null && n.getParent() != null && n.getParent().getNodeType().equals("PP")){ return "Y"; } return "N"; }
private static String calcNPunderVP(TreebankNode n){ if(n != null && n.getParent() != null && n.getParent().getNodeType().equals("VP")){ return "Y"; } return "N"; }
private static String calcNPunderS(TreebankNode n){ if(n != null && n.getParent() != null && n.getParent().getNodeType().equals("S")){ return "Y"; } return "N"; }
public boolean calcNPSubj(TreebankNode n){ if(n == null) return false; if(n.getNodeType().equals("NP")){ StringArray tags = n.getNodeTags(); if(tags != null && tags.size() > 0){ for(int i = 0; i < tags.size(); i++){ if(tags.get(i).equals("SBJ")){ return true; } } } } return false; }
public boolean calcNPSubj(TreebankNode n){ if(n == null) return false; if(n.getNodeType().equals("NP")){ StringArray tags = n.getNodeTags(); if(tags != null && tags.size() > 0){ for(int i = 0; i < tags.size(); i++){ if(tags.get(i).equals("SBJ")){ return true; } } } } return false; }
private static SimpleTree sameTree(TreebankNode t1, TreebankNode t2){ SimpleTree node = new SimpleTree(t1.getNodeType()); node.addChild(new SimpleTree("ANTECEDENT")); node.children.get(0).addChild(new SimpleTree("antecedent")); node.addChild(new SimpleTree("ANAPHOR")); node.children.get(1).addChild(new SimpleTree("anaphor")); return node; }
private static SimpleTree sameTree(TreebankNode t1, TreebankNode t2){ SimpleTree node = new SimpleTree(t1.getNodeType()); node.addChild(new SimpleTree("ANTECEDENT")); node.children.get(0).addChild(new SimpleTree("antecedent")); node.addChild(new SimpleTree("ANAPHOR")); node.children.get(1).addChild(new SimpleTree("anaphor")); return node; }
public static SimpleTree getSimpleClone(TreebankNode node) { SimpleTree t = new SimpleTree(node.getNodeType()); if(node instanceof TerminalTreebankNode){ t.addChild(new SimpleTree(node.getNodeValue())); }else{ for(int i = 0; i < node.getChildren().size(); i++){ t.addChild(getSimpleClone(node.getChildren(i))); } } return t; }
public static SimpleTree getSimpleClone(TreebankNode node) { SimpleTree t = new SimpleTree(node.getNodeType()); if(node instanceof TerminalTreebankNode){ t.addChild(new SimpleTree(node.getNodeValue())); }else{ for(int i = 0; i < node.getChildren().size(); i++){ t.addChild(getSimpleClone(node.getChildren(i))); } } return t; }
private static SimpleTree buildSimpleClonePET(TreebankNode lca, TreebankNode t1, TreebankNode t2){ SimpleTree t = new SimpleTree(lca.getNodeType()); if(lca instanceof TerminalTreebankNode){ t.addChild(new SimpleTree(lca.getNodeValue())); }else{ for(int i = 0; i < lca.getChildren().size(); i++){ TreebankNode tn = lca.getChildren(i); if(tn.getEnd() > t1.getBegin() && tn.getBegin() < t2.getEnd()){ t.addChild(buildSimpleClonePET(lca.getChildren(i), t1, t2)); } } } return t; }
private static SimpleTree buildSimpleClonePET(TreebankNode lca, TreebankNode t1, TreebankNode t2){ SimpleTree t = new SimpleTree(lca.getNodeType()); if(lca instanceof TerminalTreebankNode){ t.addChild(new SimpleTree(lca.getNodeValue())); }else{ for(int i = 0; i < lca.getChildren().size(); i++){ TreebankNode tn = lca.getChildren(i); if(tn.getEnd() > t1.getBegin() && tn.getBegin() < t2.getEnd()){ t.addChild(buildSimpleClonePET(lca.getChildren(i), t1, t2)); } } } return t; }