Пример #1
0
        /// <summary>
        /// Calculate similarity and return a list of tuples with the user and how similar it is.
        /// </summary>
        public IEnumerable <Tuple <User, float> > ListSimilarities(Similarity similarity, float threshold = 1)
        {
            var users = new List <Tuple <User, float> >();

            foreach (var user in Users)
            {
                var data   = new SimilarityList(user.Ratings, User.Ratings, Articles);
                var result = (float)similarity.Calculate(data);

                if (result < threshold)
                {
                    continue;
                }

                users.Add(new Tuple <User, float>(user, result));
            }

            // Sort
            users.Sort((x, y) => y.Item2.CompareTo(x.Item2));

            return(users);
        }
Пример #2
0
 /// <summary>
 /// Performs calculation on similarity service.
 /// </summary>
 private double Calculate(Similarity similarity)
 {
     return(similarity.Calculate(Data));
 }