示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void process(int optionContainerIndex) throws org.maltparser.core.exception.MaltChainedException
        public virtual void process(int optionContainerIndex)
        {
            FlowChartInstance flowChartInstance = flowChartInstances[optionContainerIndex];

            if (flowChartInstance.hasPreProcessChartItems())
            {
                flowChartInstance.preprocess();
            }
            if (flowChartInstance.hasProcessChartItems())
            {
                int signal          = ChartItem.CONTINUE;
                int tic             = 0;
                int sentenceCounter = 0;
                int nIteration      = 1;
                flowChartInstance.setEngineRegistry("iterations", nIteration);
                System.GC.Collect();
                while (signal != ChartItem.TERMINATE)
                {
                    signal = flowChartInstance.process();
                    if (signal == ChartItem.CONTINUE)
                    {
                        sentenceCounter++;
                    }
                    else if (signal == ChartItem.NEWITERATION)
                    {
                        SystemLogger.logger().info("\n=== END ITERATION " + nIteration + " ===\n");
                        nIteration++;
                        flowChartInstance.setEngineRegistry("iterations", nIteration);
                    }
                    if (sentenceCounter < 101 && sentenceCounter == 1 || sentenceCounter == 10 || sentenceCounter == 100)
                    {
                        Util.startTicer(SystemLogger.logger(), startTime, 10, sentenceCounter);
                    }
                    if (sentenceCounter % 100 == 0)
                    {
                        tic = Util.simpleTicer(SystemLogger.logger(), startTime, 10, tic, sentenceCounter);
                    }
                }
                Util.endTicer(SystemLogger.logger(), startTime, 10, tic, sentenceCounter);
            }
            if (flowChartInstance.hasPostProcessChartItems())
            {
                flowChartInstance.postprocess();
            }
        }
示例#2
0
        /// <summary>
        /// Initialize a parser model that later can by used to parse sentences. MaltParser is controlled by a commandLine string, please see the documentation of MaltParser to see all available options.
        /// </summary>
        /// <param name="commandLine"> a commandLine string that controls the MaltParser </param>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initializeParserModel(String commandLine) throws org.maltparser.core.exception.MaltChainedException
        public virtual void initializeParserModel(string commandLine)
        {
            if (optionContainer == -1)
            {
                throw new MaltChainedException("MaltParserService has been initialized as an option free initialization and therefore no parser model can be initialized.");
            }
            OptionManager.instance().parseCommandLine(commandLine, optionContainer);
            // Creates an engine
            engine = new Engine();
            // Initialize the engine with option container and gets a flow chart instance
            flowChartInstance = engine.initialize(optionContainer);
            // Runs the preprocess chart items of the "parse" flow chart
            if (flowChartInstance.hasPreProcessChartItems())
            {
                flowChartInstance.preprocess();
            }
            singleMalt = (SingleMalt)flowChartInstance.getFlowChartRegistry(typeof(SingleMalt), "singlemalt");
            singleMalt.ConfigurationDir.initDataFormat();
            dataFormatInstance = singleMalt.ConfigurationDir.DataFormatManager.InputDataFormatSpec.createDataFormatInstance(singleMalt.SymbolTables, OptionManager.instance().getOptionValueString(optionContainer, "singlemalt", "null_value"));
            initialized        = true;
        }