Beispiel #1
0
        public void Run()
        {
            DateTime expSt = DateTime.Now;

            Console.WriteLine("========================================================================");
            Console.WriteLine(" Metoda porównania: " + comparators[comparatorId].GetType());
            Console.WriteLine("========================================================================");
            WordsStats stats = new WordsStats(Words.ComputeWords(DataStore.Instance.GetAllNews()));

            stats.Compute();

            List <string> experimentTopics;

            if (topics != null)
            {
                experimentTopics = new List <string>();
                experimentTopics.AddRange(topics);
            }
            else
            {
                experimentTopics = GetRandomTopics(topicCount);
            }


            Group initialGroup = GroupFactory.CreateGroupWithNewsFromTopics(experimentTopics);


            Console.WriteLine("========================================================================");
            Console.WriteLine("Topiki w grupie początkowej:");
            foreach (string topic in experimentTopics)
            {
                Console.WriteLine(topic + " [" + Util.topicCountInGroup(topic, initialGroup) + "]");
            }

            Console.WriteLine("Rozmiar grupy: " + initialGroup.Count);
            ;

            DateTime start;
            TimeSpan t1, t2;


            Hierarchical hr = new Hierarchical(comparators[comparatorId], stats, maxLen);
            Kmeans       km = new Kmeans(comparators[comparatorId], stats, maxLen);

            Console.WriteLine("========================================================================");

            if (!onlyKMeans)
            {
                start = DateTime.Now;
                List <Group> hierarchicalResult = hr.Compute(initialGroup, topicCount != 0 ? topicCount : (uint)topics.Length,
                                                             Hierarchical.Distance.AVG);
                t1 = (DateTime.Now - start);
                PrintStats("Hierachical", t1, hierarchicalResult, 0);
            }

            start = DateTime.Now;
            List <Group> kMeansResult = km.Compute(initialGroup, topicCount != 0 ? topicCount : (uint)topics.Length, kMeansIterations);

            t2 = (DateTime.Now - start);
            PrintStats("KMeans", t2, kMeansResult, kMeansIterations);


            Console.WriteLine("========================================================================");
            Console.WriteLine("Czas działania: " + (DateTime.Now - expSt));
        }