public void ReviewersThatHaveReviewedUniqueTitlesShouldNotBeSimilar()
 {
     var r1 = ReviewerBuilder.BuildReviewer1();
     var r2 = ReviewerBuilder.BuildAReviewerThatReviewedSomethingUnique();
     euclideanDistance = new EuclideanDistance(r1, r2);
     Assert.AreEqual(0, euclideanDistance.Score());
 }
        public List<string> Calculate()
        {
            var scores = new Dictionary<string, double>();
            var count = new Dictionary<string, double>();

            foreach (var r in Reviewers)
            {

                var similarityScore = new EuclideanDistance(CurrentUser, r).Score();
                if (similarityScore <= 0)
                {
                    continue;
                }
                var oppositeItems = new FindOppositeReviews(CurrentUser.Reviews, r.Reviews).Calculate();

                foreach (var item in oppositeItems)
                {
                    var weightedScore = r.Reviews[item] * similarityScore;
                    if (scores.ContainsKey(item))
                    {
                        count[item]++;
                        scores[item] += weightedScore;
                    }
                    else
                    {
                        scores.Add(item, weightedScore);
                        count.Add(item, 1);
                    }
                }

            }

            var sortedRecommendations = CalculateSortedRecommendations(scores, count);
            return sortedRecommendations.Keys.ToList();
        }
        private static void RunEuclideanDistanceWithLowScore()
        {
            var r1 = ReviewerBuilder.BuildReviewer1();
            var r2 = ReviewerBuilder.BuildReviewer2();
            var euclideanDistance = new EuclideanDistance(r1, r2);

            Console.WriteLine("The Euclidean Distance between {0} and {1} is: {2}", r1.Name, r2.Name, euclideanDistance.Score());
        }
 public void TwoReviewersWithSomeSimilarReviewsShouldHaveAPositiveScoreRegardlessOfOrder()
 {
     euclideanDistance = new EuclideanDistance(ReviewerBuilder.BuildReviewer7(), ReviewerBuilder.BuildReviewer6());
     Assert.AreEqual(0.148, euclideanDistance.Score());
 }
 public void ShouldReturnASimilarityScoreOfZeroWhenBothUsersHaveNoSimilarReviews()
 {
     var r = ReviewerBuilder.BuildReviewerWithNoReviews();
     euclideanDistance = new EuclideanDistance(r, r);
     Assert.AreEqual(0.0, euclideanDistance.Score());
 }
 public void SetUp()
 {
     euclideanDistance = new EuclideanDistance(ReviewerBuilder.BuildReviewer1(), ReviewerBuilder.BuildReviewer2());
 }
 public void ReviewersWithIdenticalReviewsShouldHaveASimilarityScoreOfOne()
 {
     var r = ReviewerBuilder.BuildReviewer1();
     euclideanDistance = new EuclideanDistance(r, r);
     Assert.AreEqual(1.0, euclideanDistance.Score());
 }
 public void ReviewersThatHaveTheSameTasteShouldHaveAPerfectScore()
 {
     var r1 = ReviewerBuilder.BuildReviewer1();
     euclideanDistance = new EuclideanDistance(r1, r1);
     Assert.AreEqual(1.0, euclideanDistance.Score());
 }