Esempio n. 1
0
        public ActionResult Details(int id = 0, int?p = 1)
        {
            Jockey jockey = db.Jockeys.Find(id);

            if (jockey == null)
            {
                return(HttpNotFound());
            }
            if (jockey.TwitterId != null)
            {
                var auth   = TwitterUtilities.GetAuthorizer();
                var ctx    = new TwitterContext(auth);
                var tweets =
                    from tweet in ctx.Status
                    where tweet.Type == StatusType.User &&
                    tweet.ScreenName == jockey.TwitterId
                    select tweet;

                if (tweets != null)
                {
                    try
                    {
                        ViewData["Tweets"] = tweets.ToList();
                    }
                    catch
                    {
                        Console.WriteLine("Tweet problem...");
                    }
                }
            }
            int page = p ?? 1;

            ViewBag.Results = db.Results.Include("Race.Meeting.Course").Include("Horse").Where(r => r.Jockey.Id == jockey.Id).OrderByDescending(r => r.Race.OffTime).ToPagedList(page, 50);
            return(View(jockey));
        }
Esempio n. 2
0
        public ActionResult Details(int id = 0, int?p = 1)
        {
            Course course = db.Courses.Include(t => t.Address).FirstOrDefault(t => t.Id == id);

            if (course == null)
            {
                return(HttpNotFound());
            }
            if (course.TwitterId != null)
            {
                var auth   = TwitterUtilities.GetAuthorizer();
                var ctx    = new TwitterContext(auth);
                var tweets =
                    from tweet in ctx.Status
                    where tweet.Type == StatusType.User &&
                    tweet.ScreenName == course.TwitterId
                    select tweet;

                if (tweets != null)
                {
                    ViewBag.Tweets = tweets.ToList();
                }
            }

            int page = p ?? 1;

            ViewBag.Races = db.Races.Where(r => r.Meeting.Course.Id == course.Id).OrderByDescending(r => r.OffTime).ToPagedList(page, 50);


            return(View(course));
        }
        public ActionResult Details(int id = 0)
        {
            Trainer trainer = db.Trainers.Include(t => t.Address).FirstOrDefault(t => t.Id == id);

            if (trainer == null)
            {
                return(HttpNotFound());
            }
            if (trainer.TwitterId != null)
            {
                var auth   = TwitterUtilities.GetAuthorizer();
                var ctx    = new TwitterContext(auth);
                var tweets =
                    from tweet in ctx.Status
                    where tweet.Type == StatusType.User &&
                    tweet.ScreenName == trainer.TwitterId
                    select tweet;

                if (tweets != null)
                {
                    ViewData["Tweets"] = tweets.ToList();
                }
            }
            return(View(trainer));
        }
        ImputeEmotionalContentFromFile(string filename, uint column, uint repeats, string imputesave)
        {
            MemorySource <string, ThreeTuple <ContinuousDistribution, ContinuousDistribution, ContinuousDistribution> > imputed = new MemorySource <string, ThreeTuple <ContinuousDistribution, ContinuousDistribution, ContinuousDistribution> >();
            ComboSource <string, ThreeTuple <ContinuousDistribution, ContinuousDistribution, ContinuousDistribution> >  combo   = new ComboSource <string, ThreeTuple <ContinuousDistribution, ContinuousDistribution, ContinuousDistribution> >(source, imputed);

            // Check for existing imputed file
            DataReader imputereader = new DataReader(imputesave);
            uint       kk           = 0;

            for (string[] row = imputereader.ReadRow(); row != null; row = imputereader.ReadRow())
            {
                kk++;
                if (kk % 1000 == 0)
                {
                    Console.WriteLine("#" + kk);
                }

                double meanv = double.Parse(row[1]), varv = double.Parse(row[2]), meana = double.Parse(row[3]), vara = double.Parse(row[4]), meand = double.Parse(row[5]), vard = double.Parse(row[6]);

                ContinuousDistribution valence = new ClippedGaussianDistribution(meanv, varv, 0, 1);
                ContinuousDistribution arousal = new ClippedGaussianDistribution(meana, vara, 0, 1);
                ContinuousDistribution dominance = new ClippedGaussianDistribution(meand, vard, 0, 1);

                imputed[row[0]] = new ThreeTuple <ContinuousDistribution, ContinuousDistribution, ContinuousDistribution>(valence, arousal, dominance);
            }
            imputereader.Close();

            for (uint ii = 0; ii < repeats; ii++)
            {
                Dictionary <string, List <KeyValuePair <double, double> > >
                sentencesV     = new Dictionary <string, List <KeyValuePair <double, double> > >(),
                    sentencesA = new Dictionary <string, List <KeyValuePair <double, double> > >(),
                    sentencesD = new Dictionary <string, List <KeyValuePair <double, double> > >();

                DataReader reader = new DataReader(filename);
                uint       jj     = 0;
                for (string[] row = reader.ReadRow(); row != null; row = reader.ReadRow())
                {
                    jj++;
                    if (jj % 1000 == 0)
                    {
                        Console.WriteLine("#" + jj + ": " + sentencesV.Count + ", " + imputed.Count);
                    }

                    List <string> words = TwitterUtilities.SplitWords(row[column].ToLower());
                    AnalyzeWords(words, combo, sentencesV, sentencesA, sentencesD);
                }
                reader.Close();

                AnalyzeSentences(imputed, sentencesV, sentencesA, sentencesD, imputesave);
            }

            source = combo;
            return(imputed);
        }