public Ratio GetPositiveAndNegativeRatioByDate(string key, string category)
        {
            WriteToFile("GetPositiveAndNegativeRatioByDate", "Start", "minmood", key);

            string url  = "http://" + HBaseIp + "/minmood/" + key;
            var    data = ConnectToHBaseService(url);

            Ratio positiveNegativeRatio = new Ratio();

            positiveNegativeRatio.negative = 0;
            positiveNegativeRatio.positive = 0;

            foreach (Row row in data.Row)
            {
                foreach (Cell cell in row.Cell)
                {
                    try
                    {
                        TweetBase tweetBase = JsonConvert.DeserializeObject <TweetBase>(this.DecodeBase64(cell.dollar));
                        if (tweetBase.category == category || category == "General")
                        {
                            decimal positiveScore = tweetBase.posScore == string.Empty ? 0 : Convert.ToDecimal(tweetBase.posScore);
                            decimal negativeScore = tweetBase.negScore == string.Empty ? 0 : Convert.ToDecimal(tweetBase.negScore);
                            if (positiveScore > negativeScore)
                            {
                                positiveNegativeRatio.positive++;
                            }
                            else if (positiveScore < negativeScore)
                            {
                                positiveNegativeRatio.negative++;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteToFile("GetPositiveAndNegativeRatioByDate", "Exception: " + ex.ToString(), "minmood", key);
                    }
                }
            }

            WriteToFile("GetPositiveAndNegativeRatioByDate", "End", "minmood", key);

            return(positiveNegativeRatio);
        }
Exemplo n.º 2
0
 public override void Setup()
 {
     _tweetBase = new TweetBase(new TwitterServiceBase());
 }
Exemplo n.º 3
0
 public override void Setup()
 {
     base.Setup();
     _tweetBase = new TweetBase(this.twitterServiceBaseStub);
 }