Beispiel #1
0
        /// <summary>
        /// Calculates Score for each review
        /// </summary>
        /// <param name="v"></param>
        private void CalculateScoreForEachReview(int v)
        {
            List <double> scores = new List <double>();

            foreach (var review in ReviewList)
            {
                try
                {
                    double score = 0;
                    var    words = review.Split(' ').ToList();
                    foreach (var word in words)
                    {
                        if (WordCountsDictionary.ContainsKey(word))
                        {
                            score += (WordCountsDictionary[word] / (v * 1.0)) * Math.Log((double)ReviewList.Count / (double)(NumberofReviewsWithWord[word]));
                        }
                    }
                    scores.Add(score / (double)words.Count);
                }
                catch (Exception)
                {
                }
            }
            ReviewListScore = scores;
        }
Beispiel #2
0
        /// <summary>
        /// Calculates Score for each review
        /// </summary>
        /// <param name="v"></param>
        private void CalculateScoreForEachReview(int v)
        {
            List <double> scores = new List <double>();

            foreach (var review in ReviewList)
            {
                double score = 0;
                try
                {
                    var words = review.Split(' ').ToList();
                    foreach (var word in words)
                    {
                        if (WordCountsDictionary.ContainsKey(word))
                        {
                            score += WordCountsDictionary[word] / (v * 1.0);
                        }
                    }
                }
                catch (Exception)
                {
                }
                scores.Add(score);
            }
            ReviewListScore = scores;
        }
Beispiel #3
0
 /// <summary>
 /// Add the input word to dictionary and increase the value if already in the dictionary
 /// </summary>
 /// <param name="word"></param>
 private void AddWordToDictionary(string word)
 {
     if (!WordCountsDictionary.ContainsKey(word))
     {
         WordCountsDictionary.Add(word, 1);
     }
     else
     {
         WordCountsDictionary[word]++;
     }
 }