public Edge addPhraseStructureEdge(PhraseStructureNode parent, PhraseStructureNode child) throws MaltChainedException { if (parent == null || child == null) { throw new MaltChainedException("Parent or child node is missing."); } else if (parent instanceof NonTerminalNode && !child.isRoot()) { Edge e = edgePool.checkOut(); e.setBelongsToGraph(this); e.setEdge((Node)parent, (Node)child, Edge.PHRASE_STRUCTURE_EDGE); graphEdges.add(e); return e; } else { throw new MaltChainedException("Parent or child node is not of correct node type."); } }
public void removePhraseStructureEdge(PhraseStructureNode parent, PhraseStructureNode child) throws MaltChainedException { if (parent == null || child == null) { throw new MaltChainedException("Parent or child node is missing."); } else if (parent instanceof NonTerminalNode && !child.isRoot()) { for (Edge e : graphEdges) { if (e.getSource() == parent && e.getTarget() == child) { e.clear(); graphEdges.remove(e); if (e instanceof GraphEdge) { edgePool.checkIn(e); } } } } else { throw new SyntaxGraphException("Head node is not a root node or a terminal node."); } }
public void removePhraseStructureEdge(PhraseStructureNode parent, PhraseStructureNode child) throws MaltChainedException { if (parent == null || child == null) { throw new MaltChainedException("Parent or child node is missing."); } else if (parent instanceof NonTerminalNode && !child.isRoot()) { for (Edge e : graphEdges) { if (e.getSource() == parent && e.getTarget() == child) { e.clear(); graphEdges.remove(e); if (e instanceof GraphEdge) { edgePool.checkIn(e); } } } } else { throw new SyntaxGraphException("Head node is not a root node or a terminal node."); } }
for (String edgeLabelColumn : edgeLabelColumns.keySet()) { table = symbolTables.getSymbolTable(edgeLabelColumns.get(edgeLabelColumn).getName()); if (t.hasParentEdgeLabel(table) && !t.getParent().isRoot() && !t.getParentEdgeLabelSymbol(table).equals(EMPTY_EDGELABEL)) { writer.write(EDGELABEL_SEPARATOR); writer.write(t.getParentEdgeLabelSymbol(table)); for (String edgeLabelColumn : edgeLabelColumns.keySet()) { table = symbolTables.getSymbolTable(edgeLabelColumns.get(edgeLabelColumn).getName()); if (nt.hasParentEdgeLabel(table) && !nt.getParent().isRoot() && !nt.getParentEdgeLabelSymbol(table).equals(EMPTY_EDGELABEL)) { writer.write(EDGELABEL_SEPARATOR); writer.write(nt.getParentEdgeLabelSymbol(table));
for (String edgeLabelColumn : edgeLabelColumns.keySet()) { table = symbolTables.getSymbolTable(edgeLabelColumns.get(edgeLabelColumn).getName()); if (t.hasParentEdgeLabel(table) && !t.getParent().isRoot() && !t.getParentEdgeLabelSymbol(table).equals(EMPTY_EDGELABEL)) { writer.write(EDGELABEL_SEPARATOR); writer.write(t.getParentEdgeLabelSymbol(table)); for (String edgeLabelColumn : edgeLabelColumns.keySet()) { table = symbolTables.getSymbolTable(edgeLabelColumns.get(edgeLabelColumn).getName()); if (nt.hasParentEdgeLabel(table) && !nt.getParent().isRoot() && !nt.getParentEdgeLabelSymbol(table).equals(EMPTY_EDGELABEL)) { writer.write(EDGELABEL_SEPARATOR); writer.write(nt.getParentEdgeLabelSymbol(table));
if (nonTerminal.getParent() == null || nonTerminal.getParent().isRoot()) { writer.write('0'); } else {
SortedMap<String, SymbolTable> edgeLabelSymbolTables = phraseStructuretDataFormatInstance.getPhraseStructureEdgeLabelSymbolTables(symbolTableHandler); SortedMap<String, SymbolTable> nodeLabelSymbolTables = phraseStructuretDataFormatInstance.getPhraseStructureNodeLabelSymbolTables(symbolTableHandler); if (!top.isRoot()) { for (String name : edgeLabelSymbolTables.keySet()) { if (top.hasParentEdgeLabel(symbolTables.getSymbolTable(name))) { phrase.append(tmp.getParent().getLabelSymbol(symbolTables.getSymbolTable(name))); } else { if (tmp.getParent().isRoot()) { String deprelDefaultRootLabel = graph.getDefaultRootEdgeLabelSymbol(symbolTables.getSymbolTable(PHRASE)); if (deprelDefaultRootLabel != null) {
public Edge addPhraseStructureEdge(PhraseStructureNode parent, PhraseStructureNode child) throws MaltChainedException { if (parent == null || child == null) { throw new MaltChainedException("Parent or child node is missing in sentence "+getSentenceID()); } else if (parent.getBelongsToGraph() != this || child.getBelongsToGraph() != this) { throw new MaltChainedException("Parent or child node is not a member of the graph in sentence "+getSentenceID()); } else if (parent == child) { throw new MaltChainedException("It is not allowed to add a phrase structure edge connecting the same node in sentence "+getSentenceID()); } else if (parent instanceof NonTerminalNode && !child.isRoot()) { Edge e = edgePool.checkOut(); e.setBelongsToGraph(this); e.setEdge((Node)parent, (Node)child, Edge.PHRASE_STRUCTURE_EDGE); graphEdges.add(e); return e; } else { throw new MaltChainedException("Parent or child node is not of correct node type."); } }
private void connectUnattachedSpines(MappablePhraseStructureGraph graph, DependencyNode depNode) throws MaltChainedException { if (!depNode.isRoot()) { PhraseStructureNode dependentSpine = (PhraseStructureNode)depNode; while (dependentSpine.getParent() != null) { dependentSpine = dependentSpine.getParent(); } if (!dependentSpine.isRoot()) { updatePhraseStructureGraph(graph,depNode.getHeadEdge(),true); } } for (int i = 0; i < depNode.getLeftDependentCount(); i++) { connectUnattachedSpines(graph, depNode.getLeftDependent(i)); } for (int i = depNode.getRightDependentCount()-1; i >= 0 ; i--) { connectUnattachedSpines(graph, depNode.getRightDependent(i)); } }
public boolean isContinuousExcludeTerminalsAttachToRoot() { int lcorner = getLeftmostProperDescendant().getIndex(); int rcorner = getRightmostProperDescendant().getIndex(); if (lcorner == rcorner) { return true; } TokenNode terminal = ((TokenStructure)getBelongsToGraph()).getTokenNode(lcorner); while (terminal.getIndex() != rcorner) { if (terminal.getParent() != null && terminal.getParent().isRoot()) { terminal = terminal.getTokenNodeSuccessor(); continue; } PhraseStructureNode tmp = terminal.getParent(); while (true) { if (tmp == this) { break; } if (tmp == null) { return false; } tmp = tmp.getParent(); } terminal = terminal.getTokenNodeSuccessor(); } return true; }
while (dependentSpine.getParent() != null && !dependentSpine.getParent().isRoot()) { dependentSpine = dependentSpine.getParent();