Beispiel #1
0
        public WeightDictionaryEntry GetElementFactorEntry(string term, SpaceModel space, SpaceLabel label = null)
        {
            WeightDictionaryEntry output = new WeightDictionaryEntry(term, 0);

            switch (resultType)
            {
            case FunctionResultTypeEnum.numeric:
                output = new WeightDictionaryEntry(term, GetElementFactor(term, space, label));
                break;

            case FunctionResultTypeEnum.numericVectorForMultiClass:
                Double[] vec = new double[space.labels.Count];
                Int32    c   = 0;
                foreach (SpaceLabel lb in space.labels)
                {
                    vec[c] = GetElementFactor(term, space, lb);
                    c++;
                }
                output = new WeightDictionaryEntry(term, vec);
                //                    output.AddEntry(term, vec);
                break;
            }

            if (!DistinctReturns.ContainsKey(output.weight))
            {
                DistinctReturns.Add(output.weight, term);
            }

            return(output);
        }
        public override double GetElementFactor(string term, SpaceModel space, SpaceLabel label = null)
        {
            if (!IsEnabled)
            {
                return(1);
            }
            if (!index.ContainsKey(term))
            {
                return(0);
            }
            Double score = index[term];

            if (!DistinctReturns.ContainsKey(score))
            {
                DistinctReturns.Add(score, term);
            }


            return(score);
        }
Beispiel #3
0
        public override double GetElementFactor(string term, SpaceModel space, SpaceLabel label = null)
        {
            Double score = 0;

            if (index.ContainsKey(term))
            {
                score = index[term];
            }
            else
            {
                score = GetScore(term);
            }

            if (!DistinctReturns.ContainsKey(score))
            {
                DistinctReturns.Add(score, term);
            }

            return(score);
        }