Beispiel #1
0
        private static void locate(PinAuthorizer tw)
        {
            System.Console.WriteLine("Please Type in how many DataLines should be taken (0 for all): ");
            int takeUserInput = Convert.ToInt32(Console.ReadLine());
            System.Console.WriteLine("Please Type in how many Datalines should be skipped (0 for none): ");
            int skipUserInput = Convert.ToInt32(Console.ReadLine());
            System.Console.WriteLine("Please type in the Information intervall: ");
            int informationIntervall = Convert.ToInt32(Console.ReadLine());
            System.Console.WriteLine("Do you want to retrieve Tweets about the progress? (0 no 1 yes)");
            int tweetInformation = Convert.ToInt32(Console.ReadLine());

            using (knowledgeObjects DB = new knowledgeObjects())
            {
                DB.Configuration.AutoDetectChangesEnabled = false;
                DB.Configuration.ValidateOnSaveEnabled = false;

                List<tweetRandomSample2> tweetsCollection = new List<tweetRandomSample2>();

                if (takeUserInput == 0)
                {

                    tweetsCollection = (List<tweetRandomSample2>)(from tweets in DB.tweetRandomSample2
                                                            orderby tweets.id
                                                            select tweets).Skip(skipUserInput).ToList();
                }
                else
                {
                    tweetsCollection = (List<tweetRandomSample2>)(from tweets in DB.tweetRandomSample2
                                                            orderby tweets.id
                                                            select tweets).Take(takeUserInput).Skip(skipUserInput).ToList();
                }

                Stopwatch stopwatch = new Stopwatch();
                TweetInformation ti = new TweetInformation();

                TimeSpan timespan = new TimeSpan();
                TimeSpan actualTime = new TimeSpan();

                TweetLoc tl = new TweetLoc(0);

                int i = 0;
                GeoNames knowledgeResult = new GeoNames();
                GeoNames tweetCountry = new GeoNames();
                foreach (var item in tweetsCollection)
                {
                    using (GeonamesDataEntities geonamesDB = new GeonamesDataEntities()) {
                        tweetCountry = (from geonames in geonamesDB.GeoNames
                                        where geonames.geonameid == item.geoNames_geoNamesId
                                        select geonames).ToList().First();
                    }

                    i++;
                    stopwatch.Start();
                    ti = new TweetInformation();
                    ti.userlocation = item.userlocation;
                    ti.timezone = item.timezone;
                    ti.longitude = item.lon;
                    ti.latitude = item.lat;
                    ti.baseDataId = item.id;
                    ti.coord = item.coord;
                    ti.randomSampleId = item.id;
                    tl.saveLocateResults(ti);
                    stopwatch.Stop();
                    actualTime += stopwatch.Elapsed;
                    timespan += stopwatch.Elapsed;
                    stopwatch.Reset();
                    if (i % informationIntervall == 0)
                    {
                        string tweetTXT = i + " T " + new RoundedTimeSpan(timespan.Ticks, 2) + " avg " + new RoundedTimeSpan(timespan.Ticks / i, 2) + " avg5k " + new RoundedTimeSpan(actualTime.Ticks / informationIntervall, 2);
                        System.Console.WriteLine(tweetTXT);
                        if (tweetInformation == 1)
                        {
                            statusUpdate("@pide2001 " + tweetTXT, tw);
                            }
                        actualTime = TimeSpan.Zero;
                    }
                }

                System.Console.WriteLine("Press any key to quit !");
                System.Console.ReadLine();

            }
        }
Beispiel #2
0
        private static void statistics(PinAuthorizer tw)
        {
            using (knowledgeObjects DB = new knowledgeObjects())
            {

                List<learningBase> tweetsCollection = new List<learningBase>();

                tweetsCollection = (List<learningBase>)(from tweets in DB.learningBase
                                                        orderby tweets.id
                                                        select tweets).ToList();

                Stopwatch stopwatch = new Stopwatch();
                TweetInformation ti = new TweetInformation();

                TimeSpan timespan = new TimeSpan();
                TimeSpan actualTime = new TimeSpan();

                TweetLoc tl = new TweetLoc(10);

                int i = 0;

                foreach (var item in tweetsCollection)
                {

                    i++;
                    stopwatch.Start();
                    ti = new TweetInformation();
                    ti.userlocation = item.userlocation;
                    ti.timezone = item.timezone;
                    ti.longitude = item.lon;
                    ti.latitude = item.lat;
                    ti.baseDataId = item.id;
                    tl.getGeographyStatistics(ti);
                    stopwatch.Stop();
                    actualTime += stopwatch.Elapsed;
                    timespan += stopwatch.Elapsed;
                    stopwatch.Reset();
                    if (i % 10 == 0)
                    {
                        string tweetTXT = i + " T " + new RoundedTimeSpan(timespan.Ticks, 2) + " avg " + new RoundedTimeSpan(timespan.Ticks / i, 2) + " avg5k " + new RoundedTimeSpan(actualTime.Ticks / 1000, 2);
                        System.Console.WriteLine(tweetTXT);
                        //statusUpdate("@pide2001 " + tweetTXT, tw);
                        actualTime = TimeSpan.Zero;
                    }
                }

                System.Console.WriteLine("Median " + tl.statistics.getMedianOfDistances());
                System.Console.WriteLine("Average " + tl.statistics.getAverageDistance());
                System.Console.WriteLine("Biggest " + tl.statistics.getBiggestDistance());
                System.Console.WriteLine("Smallest " + tl.statistics.getSmallestDistance());
                Tuple<GeographyData, TweetKnowledgeObj> know = tl.statistics.getBiggestDistanceAndInformation();
                System.Console.WriteLine("Biggest distance between " + know.Item1.geonamesId + " and " + know.Item2.baseDataId);

                System.Console.WriteLine("Press any key to quit !");
                System.Console.ReadLine();

            }
        }
Beispiel #3
0
        private static void learning(PinAuthorizer tw)
        {
            System.Console.WriteLine("Please Type in how many LearningData should be taken (0 for all): ");
            int takeUserInput = Convert.ToInt32(Console.ReadLine());
            System.Console.WriteLine("Please Type in how many Datalines should be skipped (0 for none): ");
            int skipUserInput = Convert.ToInt32(Console.ReadLine());
            System.Console.WriteLine("Please choose the amount of Data which should be saved to the Database in one step: ");
            int bulkInsertSizeUserInput = Convert.ToInt32(Console.ReadLine());
            System.Console.WriteLine("Please type in the Information intervall: ");
            int informationIntervall = Convert.ToInt32(Console.ReadLine());
            System.Console.WriteLine("Do you want to retrieve Tweets about the progress? (0 no 1 yes)");
            int tweetInformation = Convert.ToInt32(Console.ReadLine());

            using (knowledgeObjects DB = new knowledgeObjects())
            {

                List<learningBase> tweetsCollection = new List<learningBase>();

                if (takeUserInput == 0)
                {

                    tweetsCollection = (List<learningBase>)(from tweets in DB.learningBase
                                                            orderby tweets.id
                                                            select tweets).Skip(skipUserInput).ToList();
                }
                else
                {
                    tweetsCollection = (List<learningBase>)(from tweets in DB.learningBase
                                                            orderby tweets.id
                                                            select tweets).Take(takeUserInput).Skip(skipUserInput).ToList();
                }

                Stopwatch stopwatch = new Stopwatch();
                TweetInformation ti = new TweetInformation();

                TimeSpan timespan = new TimeSpan();
                TimeSpan actualTime = new TimeSpan();
                int bulkinsertSize = bulkInsertSizeUserInput;

                TweetLoc tl = new TweetLoc(bulkinsertSize);
                int i = 0;

                foreach (var item in tweetsCollection)
                {
                    if (i % bulkinsertSize == 0)
                    {
                        tl = new TweetLoc(bulkinsertSize);
                    }
                    i++;
                    stopwatch.Start();
                    ti = new TweetInformation();
                    ti.userlocation = item.userlocation;
                    ti.timezone = item.timezone;
                    ti.longitude = item.lon;
                    ti.latitude = item.lat;
                    ti.baseDataId = item.id;
                    tl.learn(ti);
                    stopwatch.Stop();
                    actualTime += stopwatch.Elapsed;
                    timespan += stopwatch.Elapsed;
                    stopwatch.Reset();

                    if (i % informationIntervall == 0)
                    {
                        string tweetTXT = i + " T " + new RoundedTimeSpan(timespan.Ticks, 2) + " avg " + new RoundedTimeSpan(timespan.Ticks / i, 2) + " avg5k " + new RoundedTimeSpan(actualTime.Ticks / informationIntervall, 2);
                        System.Console.WriteLine(tweetTXT);
                        if (tweetInformation == 1)
                        {
                            statusUpdate("@pide2001 " + tweetTXT, tw);
                        }
                        actualTime = TimeSpan.Zero;
                    }
                }
                System.Console.WriteLine("Press any key to quit !");
                System.Console.ReadLine();

            }
        }