/// <summary>
        /// Generates the sentiment result.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>SentimentsResult.</returns>
        public SentimentsResult GenerateSentimentResult(string name)
        {
            var sentiResult = new SentimentsResult();

            sentiResult.Date     = this.newDate.Date;
            sentiResult.Name     = name;
            sentiResult.Positive = 0;
            sentiResult.Negative = 0;
            sentiResult.Score    = 0;

            foreach (var d in this.DocScore)
            {
                if (d.Value > 0)
                {
                    sentiResult.Positive = sentiResult.Positive + 1;
                }
                else
                {
                    sentiResult.Negative = sentiResult.Negative + 1;
                }
                sentiResult.Score = sentiResult.Score + (decimal)d.Value;
            }
            var sum = (sentiResult.Positive + sentiResult.Negative) == 0?1:(sentiResult.Positive + sentiResult.Negative);

            sentiResult.Score = sentiResult.Score / sum;

            return(sentiResult);
        }
 /// <summary>
 /// Updates the senti table.
 /// </summary>
 /// <param name="postFix">The user identifier.</param>
 /// <param name="SentiResult">The senti result.</param>
 public void UpdateSentiTable(string postFix, SentimentsResult SentiResult)
 {
     using (var db = ContextFactory.GetProfileContext())
     {
         string query = $"select max(Id) from NewsStreamHourly_{postFix}";
         SentiResult.MaxId = db.Database.SqlQuery <long>(query).FirstOrDefault();
         query             =
             $"Insert into SentimentsResult_{postFix} Values ('{SentiResult.Date}', N'{SentiResult.Name}', {SentiResult.Positive}, {SentiResult.Negative}, {SentiResult.Score}, {SentiResult.MaxId})";
         db.Database.ExecuteSqlCommand(query);
     }
 }