Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.core.feature.FeatureVector predictExtract(org.maltparser.core.feature.FeatureModel featureModel, org.maltparser.parser.history.action.GuideDecision decision) throws org.maltparser.core.exception.MaltChainedException
        public virtual FeatureVector predictExtract(FeatureModel featureModel, GuideDecision decision)
        {
            if (decision is SingleDecision)
            {
                throw new GuideException("A sequantial decision model expect a sequence of decisions, not a single decision. ");
            }
            featureModel.update();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.parser.history.action.SingleDecision singleDecision = ((org.maltparser.parser.history.action.MultipleDecision)decision).getSingleDecision(decisionIndex);
            SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex);

            if (instanceModel == null)
            {
                initInstanceModel(featureModel, singleDecision.TableContainer.TableContainerName);
            }

            FeatureVector fv = instanceModel.predictExtract(featureModel.getFeatureVector(branchedDecisionSymbols, singleDecision.TableContainer.TableContainerName), singleDecision);

            if (singleDecision.continueWithNextDecision() && decisionIndex + 1 < decision.numberOfDecisions())
            {
                if (nextDecisionModel == null)
                {
                    initNextDecisionModel(((MultipleDecision)decision).getSingleDecision(decisionIndex + 1), branchedDecisionSymbols);
                }
                nextDecisionModel.predictExtract(featureModel, decision);
            }
            return(fv);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.core.feature.FeatureVector predictExtract(org.maltparser.core.feature.FeatureModel featureModel, org.maltparser.parser.history.action.GuideDecision decision) throws org.maltparser.core.exception.MaltChainedException
        public virtual FeatureVector predictExtract(FeatureModel featureModel, GuideDecision decision)
        {
            if (decision is SingleDecision)
            {
                throw new GuideException("A branched decision model expect more than one decisions. ");
            }
            featureModel.update();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.parser.history.action.SingleDecision singleDecision = ((org.maltparser.parser.history.action.MultipleDecision)decision).getSingleDecision(decisionIndex);
            SingleDecision singleDecision = ((MultipleDecision)decision).getSingleDecision(decisionIndex);

            if (instanceModel == null)
            {
                initInstanceModel(featureModel, singleDecision.TableContainer.TableContainerName);
            }
            FeatureVector fv = instanceModel.predictExtract(featureModel.getFeatureVector(branchedDecisionSymbols, singleDecision.TableContainer.TableContainerName), singleDecision);

            if (decisionIndex + 1 < decision.numberOfDecisions())
            {
                if (singleDecision.continueWithNextDecision())
                {
                    DecisionModel child = children[singleDecision.DecisionCode];
                    if (child == null)
                    {
                        child = initChildDecisionModel(((MultipleDecision)decision).getSingleDecision(decisionIndex + 1), branchedDecisionSymbols + (branchedDecisionSymbols.Length == 0?"":"_") + singleDecision.DecisionSymbol);
                        children[singleDecision.DecisionCode] = child;
                    }
                    child.predictExtract(featureModel, decision);
                }
            }

            return(fv);
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public org.maltparser.core.feature.FeatureVector predictExtract(org.maltparser.core.feature.FeatureModel featureModel, org.maltparser.parser.history.action.GuideDecision decision) throws org.maltparser.core.exception.MaltChainedException
        public virtual FeatureVector predictExtract(FeatureModel featureModel, GuideDecision decision)
        {
            featureModel.update();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.parser.history.action.SingleDecision singleDecision = (decision instanceof org.maltparser.parser.history.action.SingleDecision)?(org.maltparser.parser.history.action.SingleDecision)decision:((org.maltparser.parser.history.action.MultipleDecision)decision).getSingleDecision(decisionIndex);
            SingleDecision singleDecision = (decision is SingleDecision)?(SingleDecision)decision:((MultipleDecision)decision).getSingleDecision(decisionIndex);

            if (instanceModel == null)
            {
                initInstanceModel(featureModel, singleDecision.TableContainer.TableContainerName);
            }
            return(instanceModel.predictExtract(featureModel.getFeatureVector(branchedDecisionSymbols, singleDecision.TableContainer.TableContainerName), singleDecision));
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public boolean predict(org.maltparser.core.feature.FeatureModel featureModel, org.maltparser.parser.history.action.ComplexDecisionAction decision, boolean one_prediction) throws org.maltparser.core.exception.MaltChainedException
        public bool predict(FeatureModel featureModel, ComplexDecisionAction decision, bool one_prediction)
        {
            if (decision.numberOfDecisions() > 2)
            {
                throw new MaltChainedException("Number of decisions is greater than two,  which is unsupported in the light-weight parser (lw.parser)");
            }
            featureModel.update();
            bool success = true;

            for (int i = 0; i < decision.numberOfDecisions(); i++)
            {
                LWClassifier classifier = null;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.maltparser.parser.history.action.SingleDecision singleDecision = decision.getSingleDecision(i);
                SingleDecision singleDecision = decision.getSingleDecision(i);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final StringBuilder classifierString = new StringBuilder();
                StringBuilder classifierString = new StringBuilder();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final StringBuilder decisionModelString = new StringBuilder();
                StringBuilder decisionModelString = new StringBuilder();
                if (singleDecision.RelationToNextDecision == RelationToNextDecision.BRANCHED)
                {
                    decisionModelString.Append("bdm");
                }
                else if (singleDecision.RelationToNextDecision == RelationToNextDecision.SEQUANTIAL)
                {
                    decisionModelString.Append("sdm");
                }
                else
                {
                    decisionModelString.Append("odm");
                }
                decisionModelString.Append(i);
                string decisionSymbol = "";
                if (i == 1 && singleDecision.RelationToNextDecision == RelationToNextDecision.BRANCHED)
                {
                    decisionSymbol = singleDecision.DecisionSymbol;
                    decisionModelString.Append(decisionSymbol);
                }
                decisionModelString.Append('.');
                FeatureVector featureVector = featureModel.getFeatureVector(decisionSymbol, singleDecision.TableContainer.TableContainerName);

                if (featureModel.hasDivideFeatureFunction())
                {
                    SingleFeatureValue featureValue = (SingleFeatureValue)featureModel.DivideFeatureFunction.FeatureValue;
                    classifierString.Append(decisionModelString);
                    classifierString.Append(string.Format("{0:D3}", featureValue.IndexCode));
                    classifierString.Append('.');
                    classifierString.Append(classifierName);
                    classifier = classifiers[classifierString.ToString()];
                    if (classifier != null)
                    {
                        FeatureVector dividefeatureVector = featureModel.getFeatureVector("/" + featureVector.SpecSubModel.SubModelName);
                        success = classifier.predict(dividefeatureVector, singleDecision, one_prediction) && success;
                        continue;
                    }
                    classifierString.Length = 0;
                }

                classifierString.Append(decisionModelString);
                classifierString.Append(classifierName);
                classifier = classifiers[classifierString.ToString()];
                if (classifier != null)
                {
                    success = classifier.predict(featureVector, singleDecision, one_prediction) && success;
                }
                else
                {
                    singleDecision.addDecision(1);
                }
                if (!singleDecision.continueWithNextDecision())
                {
                    break;
                }
            }
            return(success);
        }