public int getDependencyNodeDepth() throws MaltChainedException { DependencyNode tmp = this; int depth = 0; while (tmp.hasHead()) { depth++; tmp = tmp.getHead(); } return depth; }
public String toStringTerminalNode(TokenNode node) { final StringBuilder sb = new StringBuilder(); final DependencyNode depnode = node; sb.append(node.toString().trim()); if (depnode.hasHead()) { sb.append('\t'); try { sb.append(depnode.getHead().getIndex()); sb.append('\t'); sb.append(depnode.getHeadEdge().toString()); } catch (MaltChainedException e) { System.err.println(e); } } sb.append('\n'); return sb.toString(); }
public String toStringTerminalNode(TokenNode node) { final StringBuilder sb = new StringBuilder(); final DependencyNode depnode = node; sb.append(node.toString().trim()); if (depnode.hasHead()) { sb.append('\t'); try { sb.append(depnode.getHead().getIndex()); sb.append('\t'); sb.append(depnode.getHeadEdge().toString()); } catch (MaltChainedException e) { System.err.println(e); } } sb.append('\n'); return sb.toString(); }
public int getDependencyNodeDepth() throws MaltChainedException { DependencyNode tmp = this; int depth = 0; while (tmp.hasHead()) { depth++; tmp = tmp.getHead(); } return depth; }
sb.append(tokens[index -1]); sb.append('\t'); sb.append(node.getHead().getIndex()); sb.append('\t'); if (node.getHeadEdge().hasLabel(deprelTable)) {
possibleSyntacticHead = breadthFirstSearchSortedByDistanceForPath(pdg, node.getHead(), node, nodePath); if (possibleSyntacticHead != null) { pdg.moveDependencyEdge(possibleSyntacticHead.getIndex(), node.getIndex()); possibleSyntacticHead = breadthFirstSearchSortedByDistanceForPath(pdg, node.getHead(), node, nodePath); if (possibleSyntacticHead != null) { pdg.moveDependencyEdge(possibleSyntacticHead.getIndex(), node.getIndex());
public DependencyNode getProperAncestor() throws MaltChainedException { if (!this.hasHead()) { return null; } DependencyNode tmp = this; while (tmp.hasHead()) { tmp = tmp.getHead(); } return tmp; }
public DependencyNode getAncestor() throws MaltChainedException { if (!this.hasHead()) { return this; } DependencyNode tmp = this; while (tmp.hasHead()) { tmp = tmp.getHead(); } return tmp; }
public DependencyNode getAncestor() throws MaltChainedException { if (!this.hasHead()) { return this; } DependencyNode tmp = this; while (tmp.hasHead()) { tmp = tmp.getHead(); } return tmp; }
private boolean needsDeprojectivizeWithHead(DependencyStructure pdg) throws MaltChainedException { for (int index : pdg.getDependencyIndices()) { if (nodeLifted.get(index)) { DependencyNode node = pdg.getDependencyNode(index); if (breadthFirstSearchSortedByDistanceForHead(pdg, node.getHead(), node, synacticHeadDeprel.get(index)) != null) { return true; } } } return false; }
private void computeRelationLength(DependencyStructure pdg) throws MaltChainedException { nodeRelationLength.add(0); for (int index : pdg.getTokenIndices()) { nodeRelationLength.add(Math.abs(pdg.getDependencyNode(index).getIndex() - pdg.getDependencyNode(index).getHead().getIndex())); } }
private boolean needsDeprojectivizeWithHead(DependencyStructure pdg, boolean[] nodeLifted, boolean[] nodePath, String[] synacticHeadDeprel, SymbolTable deprelSymbolTable) throws MaltChainedException { for (int index : pdg.getDependencyIndices()) { if (nodeLifted[index]) { DependencyNode node = pdg.getDependencyNode(index); if (breadthFirstSearchSortedByDistanceForHead(pdg, node.getHead(), node, synacticHeadDeprel[index], nodePath, deprelSymbolTable) != null) { return true; } } } return false; }
public DependencyNode getProperAncestor() throws MaltChainedException { if (!this.hasHead()) { return null; } DependencyNode tmp = this; while (tmp.hasHead() && !tmp.isRoot()) { tmp = tmp.getHead(); } return tmp; }
private boolean projectiveInterval(DependencyStructure parse, DependencyNode left, DependencyNode right) throws MaltChainedException { final int l = swapArray.get(left.getIndex()); final int r = swapArray.get(right.getIndex()); DependencyNode node = null; if (l > r) { return false; } else { for (int i = l + 1; i < r; i++) { for (int j = 0; j < swapArray.size(); j++) { if (swapArray.get(j) == i) { node = parse.getDependencyNode(j); break; } } while (node.hasHead()) { node = node.getHead(); } if (!(node == left || node == right)) { return false; } } return true; } }
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; }
private boolean deprojectivizeWithHead(DependencyStructure pdg, DependencyNode node, boolean[] nodeLifted, boolean[] nodePath, String[] synacticHeadDeprel, SymbolTable deprelSymbolTable) throws MaltChainedException { boolean success = true, childSuccess = false; int i, childAttempts = (counter < 10000 ? 2 : 1); DependencyNode possibleSyntacticHead; String syntacticHeadDeprel; counter++; if (nodeLifted[node.getIndex()]) { syntacticHeadDeprel = synacticHeadDeprel[node.getIndex()]; possibleSyntacticHead = breadthFirstSearchSortedByDistanceForHead(pdg, node.getHead(), node, syntacticHeadDeprel, nodePath, deprelSymbolTable); if (possibleSyntacticHead != null) { pdg.moveDependencyEdge(possibleSyntacticHead.getIndex(), node.getIndex()); nodeLifted[node.getIndex()] = false; } else { success = false; } } while (!childSuccess && childAttempts > 0) { childSuccess = true; List<DependencyNode> children = node.getListOfDependents(); for (i = 0; i < children.size(); i++) { if (!deprojectivizeWithHead(pdg, children.get(i), nodeLifted, nodePath, synacticHeadDeprel, deprelSymbolTable)) { childSuccess = false; } } childAttempts--; } return childSuccess && success; }
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; }
final DependencyNode node = (DependencyNode)addressFunction.getAddressValue().getAddress(); if (!node.isRoot()) { if (node.getHead().getIndex() < node.getIndex()) { featureValue.setIndexCode(table.getSymbolStringToCode("LEFT")); featureValue.setValue(1);