private DependencyNode findComponent(DependencyNode x) { if (x != x.getComponent()) { x.setComponent(findComponent(x.getComponent())); } return x.getComponent(); }
private DependencyNode findComponent(DependencyNode x) { if (x != x.getComponent()) { x.setComponent(findComponent(x.getComponent())); } return x.getComponent(); }
public int getLeftmostDescendantIndex() throws MaltChainedException { ComparableNode node = getLeftmostProperDescendant(); return (node != null)?node.getIndex():this.getIndex(); }
public int getRightmostDescendantIndex() throws MaltChainedException { ComparableNode node = getRightmostProperDescendant(); return (node != null)?node.getIndex():this.getIndex(); }
protected DependencyNode link(DependencyNode x, DependencyNode y) throws MaltChainedException { if (x.getRank() > y.getRank()) { y.setComponent(x); } else { x.setComponent(y); if (x.getRank() == y.getRank()) { y.setRank(y.getRank()+1); } return y; } return x; }
private boolean checkRightDependent(DependencyStructure gold, DependencyStructure parseDependencyGraph, int index) throws MaltChainedException { if (gold.getTokenNode(index).getRightmostDependent() == null) { return true; } else if (parseDependencyGraph.getTokenNode(index).getRightmostDependent() != null) { if (gold.getTokenNode(index).getRightmostDependent().getIndex() == parseDependencyGraph.getTokenNode(index).getRightmostDependent().getIndex()) { return true; } } return false; }
private void updateDependenyLabels(MappablePhraseStructureGraph graph) throws MaltChainedException { for (int index :graph.getTokenIndices()) { PhraseStructureNode top = (PhraseStructureNode)graph.getTokenNode(index); while (top != null && top.getParent() != null &&graph.getTokenNode(index) == ((NonTerminalNode)top.getParent()).getLexicalHead(headRules)) { top = top.getParent(); } lockUpdate = true; labelDependencyEdge(graph, graph.getTokenNode(index).getHeadEdge(), top); lockUpdate = false; } }
public int getLeftmostProperDescendantIndex() throws MaltChainedException { ComparableNode node = getLeftmostProperDescendant(); return (node != null)?node.getIndex():-1; }
public int getRightmostProperDescendantIndex() throws MaltChainedException { ComparableNode node = getRightmostProperDescendant(); return (node != null)?node.getIndex():-1; }
public TokenNode identifyHead(HeadRules headRules) throws MaltChainedException { PhraseStructureNode headChild = identifyHeadChild(headRules); TokenNode lexicalHead = null; if (headChild instanceof NonTerminalNode) { lexicalHead = ((NonTerminalNode)headChild).identifyHead(headRules); } else if (headChild instanceof TokenNode) { lexicalHead = (TokenNode)headChild; } for (PhraseStructureNode node : children) { if (node != headChild && node instanceof NonTerminalNode) { ((NonTerminalNode)node).identifyHead(headRules); } } return lexicalHead; }
public ComparableNode getRightmostProperDescendant() { NonTerminalNode node = this; PhraseStructureNode candidate = null; while (node != null) { candidate = node.getRightChild(); if (candidate == null || candidate instanceof TokenNode) { return candidate; } node = (NonTerminalNode)candidate; } return null; }
public boolean equals(Object obj) { Token v = (Token)obj; if (!(this.predecessor == v.predecessor && this.successor == v.successor)) return false; return super.equals(obj); }
public ComparableNode getLeftmostProperDescendant() { NonTerminalNode node = this; PhraseStructureNode candidate = null; while (node != null) { candidate = node.getLeftChild(); if (candidate == null || candidate instanceof TokenNode) { return candidate; } node = (NonTerminalNode)candidate; } return null; }