コード例 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(org.maltparser.core.flow.FlowChartInstance flowChartinstance, org.maltparser.core.flow.spec.ChartItemSpecification chartItemSpecification) throws org.maltparser.core.exception.MaltChainedException
        public override void initialize(FlowChartInstance flowChartinstance, ChartItemSpecification chartItemSpecification)
        {
            base.initialize(flowChartinstance, chartItemSpecification);
            foreach (string key in chartItemSpecification.ChartItemAttributes.Keys)
            {
                if (key.Equals("id"))
                {
                    idName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("source"))
                {
                    sourceName = chartItemSpecification.ChartItemAttributes[key];
                }
            }
            if (ReferenceEquals(idName, null))
            {
                idName = getChartElement("analyzer").Attributes.get("id").DefaultValue;
            }
            else if (ReferenceEquals(sourceName, null))
            {
                sourceName = getChartElement("analyzer").Attributes.get("source").DefaultValue;
            }
            task      = OptionManager.instance().getOptionValue(OptionContainerIndex, "analyzer", "task").ToString();
            configDir = (ConfigurationDir)flowChartinstance.getFlowChartRegistry(typeof(ConfigurationDir), idName);
            open(task + ".dat", OptionManager.instance().getOptionValue(OptionContainerIndex, "input", "charset").ToString());
        }
コード例 #2
0
ファイル: Engine.cs プロジェクト: Sojaner/NMaltParser
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.core.flow.FlowChartInstance initialize(int optionContainerIndex) throws org.maltparser.core.exception.MaltChainedException
        public virtual FlowChartInstance initialize(int optionContainerIndex)
        {
            string flowChartName = null;

            if (OptionManager.instance().getOptionValueNoDefault(optionContainerIndex, "config", "flowchart") != null)
            {
                flowChartName = OptionManager.instance().getOptionValue(optionContainerIndex, "config", "flowchart").ToString();
            }
            if (ReferenceEquals(flowChartName, null))
            {
                if (OptionManager.instance().getOptionValueNoDefault(optionContainerIndex, "singlemalt", "mode") != null)
                {
                    // This fix maps --singlemalt-mode option to --config-flowchart option because of historical reasons (version 1.0-1.1)
                    flowChartName = OptionManager.instance().getOptionValue(optionContainerIndex, "singlemalt", "mode").ToString();
                    OptionManager.instance().overloadOptionValue(optionContainerIndex, "config", "flowchart", flowChartName);
                }
                else
                {
                    flowChartName = OptionManager.instance().getOptionValue(optionContainerIndex, "config", "flowchart").ToString();
                }
            }
            FlowChartInstance flowChartInstance = flowChartManager.initialize(optionContainerIndex, flowChartName);

            flowChartInstances[optionContainerIndex] = flowChartInstance;
            return(flowChartInstance);
        }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(org.maltparser.core.flow.FlowChartInstance flowChartinstance, org.maltparser.core.flow.spec.ChartItemSpecification chartItemSpecification) throws org.maltparser.core.exception.MaltChainedException
        public override void initialize(FlowChartInstance flowChartinstance, ChartItemSpecification chartItemSpecification)
        {
            base.initialize(flowChartinstance, chartItemSpecification);

            foreach (string key in chartItemSpecification.ChartItemAttributes.Keys)
            {
                if (key.Equals("id"))
                {
                    idName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("structure"))
                {
                    structureName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("task"))
                {
                    taskName = chartItemSpecification.ChartItemAttributes[key];
                }
            }
            if (ReferenceEquals(idName, null))
            {
                idName = getChartElement("graph").Attributes.get("id").DefaultValue;
            }
            else if (ReferenceEquals(structureName, null))
            {
                structureName = getChartElement("graph").Attributes.get("structure").DefaultValue;
            }
            else if (ReferenceEquals(taskName, null))
            {
                taskName = getChartElement("graph").Attributes.get("task").DefaultValue;
            }
        }
コード例 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(org.maltparser.core.flow.FlowChartInstance flowChartinstance, org.maltparser.core.flow.spec.ChartItemSpecification chartItemSpecification) throws org.maltparser.core.exception.MaltChainedException
        public override void initialize(FlowChartInstance flowChartinstance, ChartItemSpecification chartItemSpecification)
        {
            base.initialize(flowChartinstance, chartItemSpecification);

            foreach (string key in chartItemSpecification.ChartItemAttributes.Keys)
            {
                if (key.Equals("target"))
                {
                    targetName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("source"))
                {
                    sourceName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("mode"))
                {
                    modeName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("task"))
                {
                    taskName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("id"))
                {
                    idName = chartItemSpecification.ChartItemAttributes[key];
                }
            }
            if (ReferenceEquals(targetName, null))
            {
                targetName = getChartElement("singlemalt").Attributes.get("target").DefaultValue;
            }
            else if (ReferenceEquals(sourceName, null))
            {
                sourceName = getChartElement("singlemalt").Attributes.get("source").DefaultValue;
            }
            else if (ReferenceEquals(modeName, null))
            {
                modeName = getChartElement("singlemalt").Attributes.get("mode").DefaultValue;
            }
            else if (ReferenceEquals(taskName, null))
            {
                taskName = getChartElement("singlemalt").Attributes.get("task").DefaultValue;
            }
            else if (ReferenceEquals(idName, null))
            {
                idName = getChartElement("singlemalt").Attributes.get("id").DefaultValue;
            }

            singleMalt = (SingleMalt)flowChartinstance.getFlowChartRegistry(typeof(SingleMalt), idName);
            if (singleMalt == null)
            {
                singleMalt = new SingleMalt();
                flowChartinstance.addFlowChartRegistry(typeof(SingleMalt), idName, singleMalt);
                flowChartinstance.addFlowChartRegistry(typeof(Configuration), idName, singleMalt);
            }
        }
コード例 #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(org.maltparser.core.flow.FlowChartInstance flowChartinstance, org.maltparser.core.flow.spec.ChartItemSpecification chartItemSpecification) throws org.maltparser.core.exception.MaltChainedException
        public override void initialize(FlowChartInstance flowChartinstance, ChartItemSpecification chartItemSpecification)
        {
            base.initialize(flowChartinstance, chartItemSpecification);

            foreach (string key in chartItemSpecification.ChartItemAttributes.Keys)
            {
                if (key.Equals("target"))
                {
                    targetName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("source"))
                {
                    sourceName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("id"))
                {
                    idName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("task"))
                {
                    taskName = chartItemSpecification.ChartItemAttributes[key];
                }
            }

            if (ReferenceEquals(targetName, null))
            {
                targetName = getChartElement("pseudoproj").Attributes.get("target").DefaultValue;
            }
            else if (ReferenceEquals(sourceName, null))
            {
                sourceName = getChartElement("pseudoproj").Attributes.get("source").DefaultValue;
            }
            else if (ReferenceEquals(idName, null))
            {
                idName = getChartElement("pseudoproj").Attributes.get("id").DefaultValue;
            }
            else if (ReferenceEquals(taskName, null))
            {
                taskName = getChartElement("pseudoproj").Attributes.get("task").DefaultValue;
            }

            PseudoProjectivity tmppproj = (PseudoProjectivity)flowChartinstance.getFlowChartRegistry(typeof(PseudoProjectivity), idName);

            if (tmppproj == null)
            {
                pproj = new PseudoProjectivity();
                flowChartinstance.addFlowChartRegistry(typeof(PseudoProjectivity), idName, pproj);
            }
            else
            {
                pproj = tmppproj;
            }
        }
コード例 #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(org.maltparser.core.flow.FlowChartInstance flowChartinstance, org.maltparser.core.flow.spec.ChartItemSpecification chartItemSpecification) throws org.maltparser.core.exception.MaltChainedException
        public override void initialize(FlowChartInstance flowChartinstance, ChartItemSpecification chartItemSpecification)
        {
            base.initialize(flowChartinstance, chartItemSpecification);

            foreach (string key in chartItemSpecification.ChartItemAttributes.Keys)
            {
                if (key.Equals("id"))
                {
                    idName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("target"))
                {
                    targetName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("optiongroup"))
                {
                    optiongroupName = chartItemSpecification.ChartItemAttributes[key];
                }
            }

            if (ReferenceEquals(idName, null))
            {
                idName = getChartElement("read").Attributes.get("id").DefaultValue;
            }
            else if (ReferenceEquals(targetName, null))
            {
                targetName = getChartElement("read").Attributes.get("target").DefaultValue;
            }
            else if (ReferenceEquals(optiongroupName, null))
            {
                optiongroupName = getChartElement("read").Attributes.get("optiongroup").DefaultValue;
            }

            InputFormatName = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "format").ToString();
            InputFileName   = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "infile").ToString();
            InputCharSet    = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "charset").ToString();
            ReaderOptions   = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "reader_options").ToString();
            if (OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "iterations") != null)
            {
                Iterations = (int?)OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "iterations").Value;
            }
            else
            {
                Iterations = 1;
            }
            SyntaxGraphReaderClass = (Type)OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "reader");

            NullValueStrategy = OptionManager.instance().getOptionValue(OptionContainerIndex, "singlemalt", "null_value").ToString();

            initInput(NullValueStrategy);
            initReader(SyntaxGraphReaderClass, InputFileName, InputCharSet, ReaderOptions, iterations);
        }
コード例 #7
0
ファイル: Engine.cs プロジェクト: Sojaner/NMaltParser
//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();
            }
        }
コード例 #8
0
ファイル: WriteChartItem.cs プロジェクト: Sojaner/NMaltParser
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(org.maltparser.core.flow.FlowChartInstance flowChartinstance, org.maltparser.core.flow.spec.ChartItemSpecification chartItemSpecification) throws org.maltparser.core.exception.MaltChainedException
        public override void initialize(FlowChartInstance flowChartinstance, ChartItemSpecification chartItemSpecification)
        {
            base.initialize(flowChartinstance, chartItemSpecification);

            foreach (string key in chartItemSpecification.ChartItemAttributes.Keys)
            {
                if (key.Equals("id"))
                {
                    idName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("source"))
                {
                    sourceName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("optiongroup"))
                {
                    optiongroupName = chartItemSpecification.ChartItemAttributes[key];
                }
            }

            if (ReferenceEquals(idName, null))
            {
                idName = getChartElement("write").Attributes.get("id").DefaultValue;
            }
            else if (ReferenceEquals(sourceName, null))
            {
                sourceName = getChartElement("write").Attributes.get("source").DefaultValue;
            }
            else if (ReferenceEquals(optiongroupName, null))
            {
                optiongroupName = getChartElement("write").Attributes.get("optiongroup").DefaultValue;
            }

            OutputFormatName       = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "format").ToString();
            OutputFileName         = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "outfile").ToString();
            OutputCharSet          = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "charset").ToString();
            WriterOptions          = OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "writer_options").ToString();
            SyntaxGraphWriterClass = (Type)OptionManager.instance().getOptionValue(OptionContainerIndex, optiongroupName, "writer");

            NullValueStrategy = OptionManager.instance().getOptionValue(OptionContainerIndex, "singlemalt", "null_value").ToString();

            initOutput(NullValueStrategy);
            initWriter(SyntaxGraphWriterClass, OutputFileName, OutputCharSet, WriterOptions);
        }
コード例 #9
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;
        }
コード例 #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(org.maltparser.core.flow.FlowChartInstance flowChartinstance, org.maltparser.core.flow.spec.ChartItemSpecification chartItemSpecification) throws org.maltparser.core.exception.MaltChainedException
        public override void initialize(FlowChartInstance flowChartinstance, ChartItemSpecification chartItemSpecification)
        {
            base.initialize(flowChartinstance, chartItemSpecification);
            foreach (string key in chartItemSpecification.ChartItemAttributes.Keys)
            {
                if (key.Equals("id"))
                {
                    idName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("target"))
                {
                    targetName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("source"))
                {
                    sourceName = chartItemSpecification.ChartItemAttributes[key];
                }
                else if (key.Equals("task"))
                {
                    taskName = chartItemSpecification.ChartItemAttributes[key];
                }
            }
            if (ReferenceEquals(idName, null))
            {
                idName = getChartElement("copy").Attributes.get("id").DefaultValue;
            }
            else if (ReferenceEquals(targetName, null))
            {
                targetName = getChartElement("copy").Attributes.get("target").DefaultValue;
            }
            else if (ReferenceEquals(sourceName, null))
            {
                sourceName = getChartElement("copy").Attributes.get("source").DefaultValue;
            }
            else if (ReferenceEquals(taskName, null))
            {
                taskName = getChartElement("copy").Attributes.get("task").DefaultValue;
            }
            usePartialTree = OptionManager.instance().getOptionValue(OptionContainerIndex, "singlemalt", "use_partial_tree").ToString().Equals("true");
        }
コード例 #11
0
        /// <summary>
        /// Initialize the chart item
        /// </summary>
        /// <param name="flowChartinstance"> the flow chart instance that the chart item belongs to </param>
        /// <param name="chartItemSpecification"> a specification of the chart item </param>
        /// <exception cref="MaltChainedException"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void initialize(org.maltparser.core.flow.FlowChartInstance flowChartinstance, org.maltparser.core.flow.spec.ChartItemSpecification chartItemSpecification) throws org.maltparser.core.exception.MaltChainedException
        public virtual void initialize(FlowChartInstance flowChartinstance, ChartItemSpecification chartItemSpecification)
        {
            FlowChartInstance      = flowChartinstance;
            ChartItemSpecification = chartItemSpecification;
        }