//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void deprojectivize(org.maltparser.core.syntaxgraph.DependencyStructure pdg, int markingStrategy) throws org.maltparser.core.exception.MaltChainedException public void deprojectivize(IDependencyStructure pdg, int markingStrategy) { SymbolTable deprelSymbolTable = pdg.SymbolTables.getSymbolTable("DEPREL"); SymbolTable ppliftedSymbolTable = pdg.SymbolTables.getSymbolTable("PPLIFTED"); SymbolTable pppathSymbolTable = pdg.SymbolTables.getSymbolTable("PPPATH"); bool[] nodeLifted = new bool[pdg.NDependencyNode()]; Arrays.fill(nodeLifted, false); bool[] nodePath = new bool[pdg.NDependencyNode()]; Arrays.fill(nodePath, false); string[] synacticHeadDeprel = new string[pdg.NDependencyNode()]; Arrays.fill(synacticHeadDeprel, null); foreach (int index in pdg.TokenIndices) { Edge e = pdg.GetDependencyNode(index).HeadEdge; if (e.hasLabel(deprelSymbolTable)) { if (e.hasLabel(pppathSymbolTable) && pppathSymbolTable.getSymbolCodeToString(e.getLabelCode(pppathSymbolTable)).Equals("#true#")) { nodePath[pdg.GetDependencyNode(index).Index] = true; } if (e.hasLabel(ppliftedSymbolTable) && !ppliftedSymbolTable.getSymbolCodeToString(e.getLabelCode(ppliftedSymbolTable)).Equals("#false#")) { nodeLifted[index] = true; if (!ppliftedSymbolTable.getSymbolCodeToString(e.getLabelCode(ppliftedSymbolTable)).Equals("#true#")) { synacticHeadDeprel[index] = ppliftedSymbolTable.getSymbolCodeToString(e.getLabelCode(ppliftedSymbolTable)); } } } } deattachCoveredRootsForDeprojectivization(pdg, deprelSymbolTable); if (markingStrategy == HEAD && needsDeprojectivizeWithHead(pdg, nodeLifted, nodePath, synacticHeadDeprel, deprelSymbolTable)) { deprojectivizeWithHead(pdg, pdg.DependencyRoot, nodeLifted, nodePath, synacticHeadDeprel, deprelSymbolTable); } else if (markingStrategy == PATH) { deprojectivizeWithPath(pdg, pdg.DependencyRoot, nodeLifted, nodePath); } else if (markingStrategy == HEADPATH) { deprojectivizeWithHeadAndPath(pdg, pdg.DependencyRoot, nodeLifted, nodePath, synacticHeadDeprel, deprelSymbolTable); } }
/// <summary> /// Creates a immutable dependency graph /// </summary> /// <param name="dataFormat"> a data format that describes the label types (or the columns in the input and output) </param> /// <param name="sourceGraph"> a dependency graph that implements the interface org.maltparser.core.syntaxgraph.DependencyStructure </param> /// <param name="defaultRootLabel"> the default root label </param> /// <exception cref="MaltChainedException"> </exception> public ConcurrentDependencyGraph(DataFormat.DataFormat dataFormat, IDependencyStructure sourceGraph, string defaultRootLabel) { DataFormat = dataFormat; nodes = new ConcurrentDependencyNode[sourceGraph.NDependencyNode()]; // Add nodes nodes[0] = new ConcurrentDependencyNode(this, 0, null); // ROOT foreach (int index in sourceGraph.TokenIndices) { DependencyNode gNode = sourceGraph.GetDependencyNode(index); string[] columns = new string[dataFormat.NumberOfColumns()]; for (int i = 0; i < dataFormat.NumberOfColumns(); i++) { ColumnDescription column = dataFormat.GetColumnDescription(i); if (!column.Internal) { if (column.Category == ColumnDescription.Input) { columns[i] = gNode.getLabelSymbol(sourceGraph.SymbolTables.getSymbolTable(column.Name)); } else if (column.Category == ColumnDescription.Head) { if (gNode.hasHead()) { columns[i] = Convert.ToString(gNode.HeadEdge.Source.Index); } else { columns[i] = Convert.ToString(-1); } } else if (column.Category == ColumnDescription.DependencyEdgeLabel) { SymbolTable sourceTable = sourceGraph.SymbolTables.getSymbolTable(column.Name); if (gNode.HeadEdge.hasLabel(sourceTable)) { columns[i] = gNode.HeadEdge.getLabelSymbol(sourceTable); } else { columns[i] = defaultRootLabel; } } else { columns[i] = "_"; } } } nodes[index] = new ConcurrentDependencyNode(this, index, columns); } }