Esempio n. 1
0
        /// <summary>
        /// Gets the top tags.
        /// </summary>
        public static ICollection <Tag> GetMostUsedTags(this ObjectProvider repository, int itemCount)
        {
            if (itemCount < 0)
            {
                throw new ArgumentOutOfRangeException("itemCount", itemCount,
                                                      Resources.ArgumentOutOfRange_NegativeTagItemCount);
            }
            var topTags = repository.GetTopTags(itemCount);

            double mean;
            double stdDev = topTags.Values.StandardDeviation(out mean);

            var tags = new List <Tag>();

            foreach (var tag in topTags)
            {
                var t = new Tag(tag);
                t.Factor = (t.Count - mean) / stdDev;
                t.Weight = ComputeWeight(t.Factor, stdDev);
                tags.Add(t);
            }

            return(tags);
        }