예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void resetTokens(String[] inputTokens, String defaultRootLabel, boolean addEdges) throws org.maltparser.core.exception.MaltChainedException
        public void resetTokens(string[] inputTokens, string defaultRootLabel, bool addEdges)
        {
            nodes.Clear();
            comments.Clear();
            symbolTables.cleanUp();
            // Add nodes
            nodes.Add(new LWNode(this, 0));             // ROOT
            for (int i = 0; i < inputTokens.Length; i++)
            {
                nodes.Add(new LWNode(this, i + 1));
            }

            for (int i = 0; i < inputTokens.Length; i++)
            {
                nodes[i + 1].addColumnLabels(inputTokens[i].Split(TAB_SIGN, true), addEdges);
            }
            // Check graph
            for (int i = 0; i < nodes.Count; i++)
            {
                if (nodes[i].HeadIndex >= nodes.Count)
                {
                    throw new LWGraphException("Not allowed to add a head node that doesn't exists");
                }
            }

            for (int i = 0; i < dataFormat.NumberOfColumns(); i++)
            {
                ColumnDescription column = dataFormat.GetColumnDescription(i);
                if (!column.Internal && column.Category == ColumnDescription.DependencyEdgeLabel)
                {
                    rootLabels.setDefaultRootLabel(symbolTables.getSymbolTable(column.Name), defaultRootLabel);
                }
            }
        }