/// <summary>
 ///     Updates the ngram usage count based on the sentiment and whether or not
 ///     the partialTweetText is a rewteet.
 /// </summary>
 /// <param name="ngram">The ngram.</param>
 /// <param name="isRetweet">
 ///     if set to <c>true</c> [is retweet].
 /// </param>
 /// <param name="sentiment">The sentiment.</param>
 public static void UpdateNgramUsageCount(NgramBase ngram, bool isRetweet, Sentiment sentiment)
 {
     if (isRetweet)
     {
         if (sentiment.Equals(Sentiment.Positive))
         {
             ngram.RtPositiveCount++;
         }
         else if (sentiment.Equals(Sentiment.Negative))
         {
             ngram.RtNegativeCount++;
         }
         else
         {
             ngram.RtNeutralCount++;
         }
     }
     else
     {
         if (sentiment.Equals(Sentiment.Positive))
         {
             ngram.PositiveCount++;
         }
         else if (sentiment.Equals(Sentiment.Negative))
         {
             ngram.NegativeCount++;
         }
         else
         {
             ngram.NeutralCount++;
         }
     }
 }
        /// <summary>
        ///     Updates the ngrams sentiment count based on the sentiment of the partialTweetText and whether
        ///     or not this ngram is part of the retweet.
        /// </summary>
        /// <param name="ngrams">The ngrams.</param>
        /// <param name="isRetweet">
        ///     if set to <c>true</c> [is retweet].
        /// </param>
        /// <param name="sentiment">The sentiment.</param>
        /// <param name="ngramDbSet">The ngram db set.</param>
        /// <param name="isStemmed">
        ///     if set to <c>true</c> [is stemmed].
        /// </param>
        /// <param name="context">The context.</param>
        public static void UpdateNgramsSentiment <TEntity>(IList <String> ngrams, bool isRetweet, Sentiment sentiment,
                                                           bool isStemmed, DbSet <TEntity> ngramDbSet,
                                                           IOclumenContext context) where TEntity : NgramBase
        {
            foreach (String currentNgram in ngrams)
            {
                NgramBase dbNgram = ngramDbSet.FirstOrDefault(x => x.Text == currentNgram);

                if (dbNgram == null)
                {
                    // ok we dont have this ngram in our database yet
                    NgramBase newNgram;

                    if (isStemmed)
                    {
                        newNgram = new StemmedNgram
                        {
                            Text        = currentNgram,
                            Cardinality = GetNgramCardinality(currentNgram)
                        };
                    }
                    else
                    {
                        newNgram = new BasicNgram {
                            Text = currentNgram, Cardinality = GetNgramCardinality(currentNgram)
                        };
                    }

                    ngramDbSet.Add((TEntity)newNgram);
                    dbNgram = newNgram;
                    context.SaveChanges();
                }

                // update the usage count
                UpdateNgramUsageCount(dbNgram, isRetweet, sentiment);
            }
        }