Пример #1
0
        //        public Boolean DoNormalizeOnDomainLevel { get; set; } = true;


        /// <summary>
        /// Gets the preset tfidf.
        /// </summary>
        /// <param name="documentLimit">The document limit.</param>
        /// <param name="log">The log.</param>
        /// <returns></returns>
        public static DocumentRankingMethod GetPreset_TFIDF(Int32 documentLimit, ILogBuilder log)
        {
            DocumentRankingMethod output = new DocumentRankingMethod();

            ScoreModel scoreModel = new ScoreModel();

            ScoreModelTermWeightFactor twf = new ScoreModelTermWeightFactor();

            twf.TermWeightModel = new Weighting.FeatureWeightModel();
            twf.TermWeightModel.LocalFunction = new TermFrequencyFunction();

            FeatureWeightFactor featureWeightFactor = new FeatureWeightFactor();

            featureWeightFactor.Settings = new GlobalFunctionSettings();
            featureWeightFactor.Settings.functionName = nameof(IDFElement);
            featureWeightFactor.Settings.weight       = 1.0;
            featureWeightFactor.Deploy(log);

            twf.TermWeightModel.GlobalFactors.Add(featureWeightFactor);
            twf.weight = 1.0;

            scoreModel.Factors.Add(twf);


            output.query           = new DocumentSelectQuery();
            output.query.SizeLimit = documentLimit;

            output.model = scoreModel;
            return(output);
        }
        /// <summary>
        /// Defines dataset filter, based on current FeatureWeightFactor model
        /// </summary>
        /// <param name="remove">If true it will remove any existing ScoreModel Factors</param>
        /// <param name="weight">Weight associated with the term weight based document score factor</param>
        /// <remarks>
        /// It will copy current FeatureWeight model as a ScoreModel factor for the DataSet filtration function
        /// </remarks>
        /// <seealso cref="aceOperationSetExecutorBase" />
        public void aceOperation_setDocumentSelectionAddTWFactor(
            [Description("If true it will remove any existing ScoreModel Factors")] Boolean remove = false,
            [Description("Model definition name")] String modelName = "*",
            [Description("Weight associated with the term weight based document score factor")] Double weight    = 1.0,
            [Description("Normalize score value on range from 0.0 to 1.0, across the sample")] Boolean normalize = true

            )
        {
            if (remove)
            {
                data.ranking.model.Factors.Clear();
                data.ranking.model.SerializedFactors.Clear();
            }

            ScoreModelTermWeightFactor twf = new ScoreModelTermWeightFactor();

            twf.modelDefinitionFile = modelName;

            // twf.TermWeightModel = weighting.data.weightModel; // toolkitSettings.corpusMethod.weightModel;
            twf.weight      = weight;
            twf.doNormalize = normalize;

            data.ranking.model.Factors.Add(twf);
        }