public PhraseStructureGraph(SymbolTableHandler symbolTables) throws MaltChainedException { super(symbolTables); root = new Root(); root.setBelongsToGraph(this); graphEdges = new TreeSet<Edge>(); edgePool = new ObjectPoolList<Edge>() { protected Edge create() { return new GraphEdge(); } public void resetObject(Edge o) throws MaltChainedException { o.clear(); } }; nonTerminalNodes = new TreeMap<Integer,NonTerminal>(); nonTerminalPool = new ObjectPoolList<NonTerminal>() { protected NonTerminal create() throws MaltChainedException { return new NonTerminal(); } public void resetObject(NonTerminal o) throws MaltChainedException { o.clear(); } }; }
public Root() throws MaltChainedException { super(); leftDependents = new TreeSet<DependencyNode>(); rightDependents = new TreeSet<DependencyNode>(); children = new TreeSet<PhraseStructureNode>(); clear(); }
public DependencyNode findComponent() { return findComponent(this); }
public boolean hasDependent() { return hasLeftDependent() || hasRightDependent(); }
public void clear() throws MaltChainedException { edgePool.checkInAll(); graphEdges.clear(); root.clear(); root.setBelongsToGraph(this); nonTerminalPool.checkInAll(); nonTerminalNodes.clear(); super.clear(); }
if ( this == o ) return EQUAL; try { final int thisLCorner = this.getLeftmostProperDescendantIndex(); final int thatLCorner = (o instanceof TokenNode)?o.getCompareToIndex():o.getLeftmostProperDescendantIndex(); final int thisRCorner = this.getRightmostProperDescendantIndex(); final int thatRCorner = (o instanceof TokenNode)?o.getCompareToIndex():o.getRightmostProperDescendantIndex();
public void addOutgoingEdge(Edge out) throws MaltChainedException { super.addOutgoingEdge(out); if (out.getTarget() != null) { if (out.getType() == Edge.DEPENDENCY_EDGE && out.getTarget() instanceof DependencyNode) { Node dependent = out.getTarget(); if (compareTo(dependent) > 0) { leftDependents.add((DependencyNode)dependent); } else if (compareTo(dependent) < 0) { rightDependents.add((DependencyNode)dependent); } } else if (out.getType() == Edge.PHRASE_STRUCTURE_EDGE && out.getTarget() instanceof PhraseStructureNode) { children.add((PhraseStructureNode)out.getTarget()); } } }
public ComparableNode getRightmostProperDescendant() throws MaltChainedException { NonTerminalNode node = this; ComparableNode candidate = null; while (node != null) { candidate = node.getRightChild(); if (candidate == null || candidate instanceof TokenNode) { break; } node = (NonTerminalNode)candidate; } if (candidate == null && candidate instanceof NonTerminalNode) { candidate = null; DependencyNode dep = null; for (int i = ((TokenStructure)getBelongsToGraph()).getHighestTokenIndex(); i > 0; i--) { dep = ((TokenStructure)getBelongsToGraph()).getTokenNode(i); while (dep != null) { if (dep == this ) { return dep; } dep = dep.getHead(); } } } return candidate; }
public ComparableNode getLeftmostDescendant() throws MaltChainedException { return getLeftmostProperDescendant(); }
public ComparableNode getRightmostDescendant() throws MaltChainedException { return getRightmostProperDescendant(); }
public void clear() throws MaltChainedException { edgePool.checkInAll(); graphEdges.clear(); root.clear(); root.setBelongsToGraph(this); nonTerminalPool.checkInAll(); nonTerminalNodes.clear(); if (mapping != null) { mapping.clear(); } super.clear(); numberOfComponents++; }
public void removeOutgoingEdge(Edge out) throws MaltChainedException { super.removeOutgoingEdge(out); if (out.getTarget() != null) { if (out.getType() == Edge.DEPENDENCY_EDGE && out.getTarget() instanceof DependencyNode) { Node dependent = out.getTarget(); if (compareTo(dependent) > 0) { leftDependents.remove((DependencyNode)dependent); } else if (compareTo(dependent) < 0) { rightDependents.remove((DependencyNode)dependent); } } else if (out.getType() == Edge.PHRASE_STRUCTURE_EDGE && out.getTarget() instanceof PhraseStructureNode) { children.remove((PhraseStructureNode)out.getTarget()); } } } public DependencyNode getPredecessor() {
public ComparableNode getLeftmostProperDescendant() throws MaltChainedException { NonTerminalNode node = this; ComparableNode candidate = null; while (node != null) { candidate = node.getLeftChild(); if (candidate == null || candidate instanceof TokenNode) { break; } node = (NonTerminalNode)candidate; } if (candidate == null && candidate instanceof NonTerminalNode) { candidate = null; DependencyNode dep = null; for (int index : ((TokenStructure)getBelongsToGraph()).getTokenIndices()) { dep = ((TokenStructure)getBelongsToGraph()).getTokenNode(index); while (dep != null) { if (dep == this ) { return dep; } dep = dep.getHead(); } } } return candidate; }
public DependencyGraph(SymbolTableHandler symbolTables) throws MaltChainedException { super(symbolTables); setSingleHeadedConstraint(true); root = new Root(); root.setBelongsToGraph(this); graphEdges = new TreeSet<Edge>(); edgePool = new ObjectPoolList<Edge>() { protected Edge create() { return new GraphEdge(); } public void resetObject(Edge o) throws MaltChainedException { o.clear(); } }; clear(); }
public void clear() throws MaltChainedException { edgePool.checkInAll(); graphEdges.clear(); root.clear(); super.clear(); numberOfComponents++; }
private DependencyNode findComponent(DependencyNode x) { if (x != x.getComponent()) { x.setComponent(findComponent(x.getComponent())); } return x.getComponent(); }
public MappablePhraseStructureGraph(SymbolTableHandler symbolTables) throws MaltChainedException { super(symbolTables); setSingleHeadedConstraint(true); root = new Root(); root.setBelongsToGraph(this); graphEdges = new TreeSet<Edge>(); edgePool = new ObjectPoolList<Edge>() { protected Edge create() { return new GraphEdge(); } public void resetObject(Edge o) throws MaltChainedException { o.clear(); } }; nonTerminalNodes = new TreeMap<Integer,NonTerminal>(); nonTerminalPool = new ObjectPoolList<NonTerminal>() { protected NonTerminal create() throws MaltChainedException { return new NonTerminal(); } public void resetObject(NonTerminal o) throws MaltChainedException { o.clear(); } }; clear(); }