Example #1
0
        public void Calculate_client_rating()
        {
            var calculator = new RatingCalculator();

            var regional = new[] { Tuple.Create(500m, 1ul) };
            var clients  = new[] { new ClientRating(100u, 1ul, 100m), };
            var rating   = calculator.Calculate(regional, clients);
            var result   = new[] { new ClientRating(100u, 1ul, 0.2m) };

            Assert.That(rating.ToArray(), Is.EquivalentTo(result));
        }
        public void Load()
        {
            double positive = 0;
            double negative = 0;

            foreach (var sentenceItem in Text.Sentences)
            {
                foreach (var word in sentenceItem.Words)
                {
                    double?value = null;
                    if (word.Value.HasValue)
                    {
                        value = word.Value;
                    }

                    if (word.CalculatedValue.HasValue)
                    {
                        value = word.CalculatedValue.Value;
                    }

                    if (value != null)
                    {
                        if (value > 0)
                        {
                            positive += Math.Abs(value.Value);
                        }
                        else
                        {
                            negative += Math.Abs(value.Value);
                        }
                    }
                }
            }

            Sentiment = RatingCalculator.Calculate(positive, negative);
        }