Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public java.util.List<String[]> parseSentences(java.util.List<String[]> inputSentences, String defaultRootLabel, int markingStrategy, boolean coveredRoot, org.maltparser.core.symbol.SymbolTableHandler parentSymbolTableHandler, org.maltparser.concurrent.graph.dataformat.DataFormat concurrentDataFormat) throws org.maltparser.core.exception.MaltChainedException
        public IList <string[]> parseSentences(IList <string[]> inputSentences, string defaultRootLabel, int markingStrategy, bool coveredRoot, SymbolTableHandler parentSymbolTableHandler, DataFormat concurrentDataFormat)
        {
            IList <string[]>      outputSentences         = Collections.synchronizedList(new List <string[]>());
            SymbolTableHandler    parseSymbolTableHandler = new ParseSymbolTableHandler(parentSymbolTableHandler);
            LWDependencyGraph     parseGraph = new LWDependencyGraph(concurrentDataFormat, parseSymbolTableHandler);
            LWDeterministicParser parser     = new LWDeterministicParser(this, parseSymbolTableHandler);

            for (int i = 0; i < inputSentences.Count; i++)
            {
                string[] tokens = inputSentences[i];
                // TODO nothing to parse
                parseGraph.resetTokens(tokens, defaultRootLabel, false);
                parser.parse(parseGraph);
                if (markingStrategy != 0 || coveredRoot)
                {
                    (new LWDeprojectivizer()).deprojectivize(parseGraph, markingStrategy);
                }
                string[] outputTokens = new string[tokens.Length];
                for (int j = 0; j < outputTokens.Length; j++)
                {
                    outputTokens[j] = parseGraph.GetDependencyNode(j + 1).ToString();
                }
                outputSentences.Add(outputTokens);
            }
            return(outputSentences);
        }
Beispiel #2
0
        /// <summary>
        /// Same as parse(String[] tokens), but instead it returns an array of tokens with a head index and a dependency type at the end of string
        /// </summary>
        /// <param name="tokens"> an array of tokens to parse </param>
        /// <returns> an array of tokens with a head index and a dependency type at the end of string </returns>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public String[] parseTokens(String[] tokens) throws org.maltparser.core.exception.MaltChainedException
        public string[] parseTokens(string[] tokens)
        {
            LWDependencyGraph outputGraph = internalParse(tokens);

            string[] outputTokens = new string[tokens.Length];
            for (int i = 0; i < outputTokens.Length; i++)
            {
                outputTokens[i] = outputGraph.GetDependencyNode(i + 1).ToString();
            }
            return(outputTokens);
        }