Esempio n. 1
0
 public clsActors(string ApplicationName, string DevKey)
 {
     _Settings = new clsSettings();
     _Collector = new clsStatMonger(DevKey, ApplicationName, _Settings.Accounts, _Settings);
     _Analyzer = new clsStatMasher(_Collector.InitialDataSet, _Collector.HistoricalDataPoints);
     _ED = new clsED(_Settings);
 }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     lb3.Items.Clear();
     clsStatMasher masher = new clsStatMasher(sm.InitialDataSet, sm.HistoricalDataPoints);
     foreach (clsVideoEntry entry in masher.InitialDataSet)
     {
         lb3.Items.Add(entry.VideoID + " - " + masher.AverageNewRatingByID(entry.VideoID).ToString() + " - " + masher.AverageNewRatingByID(entry.VideoID, 1).ToString());
     }
 }
Esempio n. 3
0
        private void button5_Click(object sender, EventArgs e)
        {
            List<clsVideoEntry> init = new List<clsVideoEntry>();

            string log = textBox3.Text;
            Regex r = new Regex("V=(.*),Views=(.*),Comments=(.*),Favorites=(.*),Ratings=(.*),ARating=(.*)");
            MatchCollection matches = r.Matches(textBox3.Text);
            foreach (Match m in matches)
            {
                Google.GData.YouTube.YouTubeEntry entry = new Google.GData.YouTube.YouTubeEntry();
                entry.VideoId = m.Groups[1].Value;
                Google.GData.Extensions.FeedLink feedlink = new Google.GData.Extensions.FeedLink();
                feedlink.CountHint = int.Parse(m.Groups[3].Value);
                entry.Comments = new Google.GData.Extensions.Comments();
                entry.Comments.FeedLink = feedlink;
                entry.Statistics = new Google.GData.YouTube.Statistics();
                entry.Statistics.ViewCount = m.Groups[2].Value;
                entry.Statistics.FavoriteCount = m.Groups[4].Value;
                entry.Rating = new Google.GData.Extensions.Rating();
                entry.Rating.NumRaters = int.Parse(m.Groups[5].Value);
                entry.Rating.Average = double.Parse(m.Groups[6].Value);
                init.Add(new clsVideoEntry(entry));
            }

            Dictionary<string, List<clsDataPoint>> hist = new Dictionary<string, List<clsDataPoint>>();
            r = new Regex("DT=.*V=(.*),field=(.*),init_v=(.*),new_v=(.*)");
            matches = r.Matches(textBox3.Text);
            foreach (Match m in matches)
            {
                string v = m.Groups[1].Value;
                string f = m.Groups[2].Value;
                double Iv = double.Parse(m.Groups[3].Value);
                double Nv = double.Parse(m.Groups[4].Value);
                if (!hist.ContainsKey(v))
                    hist.Add(v, new List<clsDataPoint>());

                clsDataPointField field = new clsDataPointField();
                switch (f)
                {
                    case "E_VIEWS":
                        field.Field = clsDataPointField.VideoDataFields.VIEWS;
                        break;
                    case "E_RATINGS":
                        field.Field = clsDataPointField.VideoDataFields.RATERS;
                        break;
                    case "E_AVERAGE_RATING":
                        field.Field = clsDataPointField.VideoDataFields.AVERAGE_RATING;
                        break;
                    case "E_COMMENTS":
                        field.Field = clsDataPointField.VideoDataFields.COMMENT_COUNT;
                        break;
                    case "E_FAVORITES":
                        field.Field = clsDataPointField.VideoDataFields.FAVORITED_COUNT;
                        break;
                }
                hist[v].Add(new clsDataPoint(Iv, Nv, field, v));
            }

            lb.Items.Clear();
            lb3.Items.Clear();

            mash = new clsStatMasher(init, hist);

            foreach (clsVideoEntry en in init)
            {
                lb.Items.Add(en.VideoID);
                lb3.Items.Add(mash.AverageNewRatingByID(en.VideoID, 10));
            }
        }
        private void redraw_chart()
        {
            ARdata = new PointPairList();
            ANRdata = new PointPairList();
            Rdata = new PointPairList();
            Cdata = new PointPairList();
            Vdata = new PointPairList();
            Fdata = new PointPairList();

            int index = cbVideo.SelectedIndex;
            if (index == -1)
                return;
            string key = _monger.InitialDataSet[index].VideoID;
            if (!_monger.HistoricalDataPoints.ContainsKey(key))
                return;
            List<clsDataPoint> dps = _monger.HistoricalDataPoints[key];
            clsStatMasher my_sm = new clsStatMasher(_monger.InitialDataSet, _monger.HistoricalDataPoints);

            double[] N = { -1, -1 };
            double[] A = { -1, -1 };

            int dp_total = dps.Count;
            double ANR = my_sm.AverageNewRatingByID(key);
            double ANR10 = my_sm.AverageNewRatingByID(key, 10).Value;
            int raters_total = 0;
            double raters_min = 0;
            int viewer_total = 0;
            double viewers_min = 0;
            int favs_total = 0;
            double favs_min = 0;

            for (int i = 0; i < dps.Count; i++)
            {
                switch (dps[i].Field.Field)
                {
                    case clsDataPointField.VideoDataFields.RATERS:
                        raters_total += (int)dps[i].Delta;
                        break;
                    case clsDataPointField.VideoDataFields.VIEWS:
                        viewer_total += (int)dps[i].Delta;
                        break;
                    case clsDataPointField.VideoDataFields.FAVORITED_COUNT:
                        favs_total += (int)dps[i].Delta;
                        break;
                }
                if (dps[i].Field.Field == clsDataPointField.VideoDataFields.AVERAGE_RATING)
                    ARdata.Add(new PointPair(dps[i].Time.Ticks, dps[i].New, dps[i].Time.ToString()));
                if (dps[i].Field.Field == clsDataPointField.VideoDataFields.AVERAGE_RATING)
                {
                    if (A[0] == -1)
                    {
                        A[0] = dps[i].Old;
                        A[1] = dps[i].New;
                    }
                    else
                    {
                        A[1] = dps[i].New;
                    }
                }
                if (dps[i].Field.Field == clsDataPointField.VideoDataFields.RATERS)
                {
                    if (N[0] == -1)
                    {
                        N[0] = dps[i].Old;
                        N[1] = dps[i].New;
                    }
                    else
                    {
                        N[1] = dps[i].New;
                    }
                }
                if (A[1] != -1 && A[0] != -1 && N[1] != -1 && N[0] != -1)
                {
                    double anr = ((A[1] * N[1]) - (A[0] * N[0])) / (N[1] - N[0]);
                    A[0] = A[1]; A[1] = -1;
                    N[0] = N[1]; N[1] = -1;
                    ANRdata.Add(new PointPair(dps[i].Time.Ticks, anr, dps[i].Time.ToString()));
                }
                if (dps[i].Field.Field == clsDataPointField.VideoDataFields.RATERS)
                    Rdata.Add(new PointPair(dps[i].Time.Ticks, dps[i].New, dps[i].Time.ToString()));
                if (dps[i].Field.Field == clsDataPointField.VideoDataFields.COMMENT_COUNT)
                    Cdata.Add(new PointPair(dps[i].Time.Ticks, dps[i].New, dps[i].Time.ToString()));
                if (dps[i].Field.Field == clsDataPointField.VideoDataFields.VIEWS)
                    Vdata.Add(new PointPair(dps[i].Time.Ticks, dps[i].New, dps[i].Time.ToString()));
                if (dps[i].Field.Field == clsDataPointField.VideoDataFields.FAVORITED_COUNT)
                    Fdata.Add(new PointPair(dps[i].Time.Ticks, dps[i].New, dps[i].Time.ToString()));
            }

            try
            {
                TimeSpan span = dps[dps.Count - 1].Time - dps[0].Time;
                int mins = span.Minutes;
                raters_min = Math.Round(raters_total / (double)mins, 4);
                viewers_min = Math.Round(viewer_total / (double)mins, 4);
                favs_min = Math.Round(favs_total / (double)mins, 4);
            }
            catch { }
            lblANR.Text = ANR.ToString();
            lblANR10.Text = ANR10.ToString();
            lblDataPointCount.Text = dp_total.ToString();
            lblFavsCount.Text = favs_total.ToString();
            lblFavsMin.Text = favs_min.ToString();
            lblRatersPerMin.Text = raters_min.ToString();
            lblRatersTotal.Text = raters_total.ToString();
            lblViewerCount.Text = viewer_total.ToString();
            lblViewersPerMin.Text = viewers_min.ToString();

            CreateChart(graphIndividual);
        }