@Override public Boolean transform(Constituent input) { return input.getOutgoingRelations().size() > 0; } };
/** * Checks if a constituent is a leaf of a tree. It is assumed that the input constituent is a * member of a TreeView. */ public static boolean isLeaf(Constituent c) { return c.getOutgoingRelations().size() == 0; }
@Override public Boolean transform(Constituent input) { return input.getOutgoingRelations().size() > 0; } }));
/** * Checks if a constituent is a leaf of a tree. It is assumed that the input constituent is a * member of a TreeView. */ public static boolean isLeaf(Constituent c) { return c.getOutgoingRelations().size() == 0; }
public List<Relation> getArguments(Constituent predicate) { if (!predicates.contains(predicate)) { throw new IllegalArgumentException("Predicate " + predicate + " not found"); } return predicate.getOutgoingRelations(); }
public List<Relation> getArguments(Constituent predicate) { if (!predicates.contains(predicate)) { throw new IllegalArgumentException("Predicate " + predicate + " not found"); } return predicate.getOutgoingRelations(); }
public static boolean isPreTerminal(Constituent treeNode) { List<Relation> out = treeNode.getOutgoingRelations(); if (out.size() == 0) return false; out = out.get(0).getTarget().getOutgoingRelations(); return out.size() == 0; }
@Override public List<Constituent> transform(Constituent input) { List<Constituent> c = new ArrayList<>(); for (Relation r : input.getOutgoingRelations()) { c.add(addPointerToSource(input, r.getTarget())); } return c; }
@Override public Boolean transform(Constituent c1) { boolean found = false; for (Relation r : c.getOutgoingRelations()) { if (r.getTarget() == c1) { found = true; break; } } return found; } };
public Constituent getHeadWord(Constituent tree) { while (tree.getOutgoingRelations().size() > 0) { tree = getHeadChild(tree); } return tree; }
@Override public Boolean transform(Constituent input) { return input.getOutgoingRelations().size() > 0 && !ParseTreeProperties.isPreTerminal(input); } });
@Override public Boolean transform(Constituent arg0) { List<Relation> relations = parent.getOutgoingRelations(); if (relations.size() <= n) return false; return relations.get(n).getTarget() == parent; } };
protected void setDependencyTreeSwitch(Constituent root) { List<Relation> rootRelations = root.getOutgoingRelations(); isDependencyTree = rootRelations.size() != 0 && !rootRelations.get(0).getRelationName().equals(PARENT_OF_STRING); }
@Override public Boolean transform(Constituent c1) { boolean found = false; for (Relation r : c.getOutgoingRelations()) { if (r.getTarget() == c1) { found = true; break; } } return found; } };
protected void setDependencyTreeSwitch(Constituent root) { List<Relation> rootRelations = root.getOutgoingRelations(); isDependencyTree = rootRelations.size() != 0 && !rootRelations.get(0).getRelationName().equals(PARENT_OF_STRING); }
@Override public Boolean transform(Constituent input) { return input.getOutgoingRelations().size() > 0 && !ParseTreeProperties.isPreTerminal(input); } });
/** * This is the meat of the headfinder. Based on the head search direction, find the head. */ private Constituent findHead(Constituent parseNode, Pair<HeadSearchDirection, String[]> rule, boolean getDefaultHeadChild) { int headChild = rule.getFirst().getHeadChildId(parseNode, rule.getSecond(), getDefaultHeadChild); if (headChild == -1) return null; headChild = fixHeadChildHacks(headChild, parseNode); return parseNode.getOutgoingRelations().get(headChild).getTarget(); }
/** * This is the meat of the headfinder. Based on the head search direction, find the head. */ private Constituent findHead(Constituent parseNode, Pair<HeadSearchDirection, String[]> rule, boolean getDefaultHeadChild) { int headChild = rule.getFirst().getHeadChildId(parseNode, rule.getSecond(), getDefaultHeadChild); if (headChild == -1) return null; headChild = fixHeadChildHacks(headChild, parseNode); return parseNode.getOutgoingRelations().get(headChild).getTarget(); }
public void removeAllRelations() { List<Constituent> allCorefCons = this.getConstituents(); for (Constituent c : allCorefCons) { for (Relation r : c.getIncomingRelations()) this.removeRelation(r); for (Relation r : c.getOutgoingRelations()) this.removeRelation(r); c.removeAllIncomingRelatons(); c.removeAllOutgoingRelaton(); } }
public void removeAllRelations() { List<Constituent> allCorefCons = this.getConstituents(); for (Constituent c : allCorefCons) { for (Relation r : c.getIncomingRelations()) this.removeRelation(r); for (Relation r : c.getOutgoingRelations()) this.removeRelation(r); c.removeAllIncomingRelatons(); c.removeAllOutgoingRelaton(); } }