Exemple #1
0
        private static void TestFeedItems(FeedService feedService)
        {
            List <Feed> feeds = feedService.GetFeeds();

            List <BagOfWords> bags = new List <BagOfWords>();

            foreach (Feed feed in feeds)
            {
                bags.AddRange(feedService.AnalyzeFeedItems(feed));
            }

            Clustering clustering = new Clustering();

            double[,] similars = new double[bags.Count, bags.Count];
            var docSimilars = new Dictionary <Tuple <BagOfWords, BagOfWords>, double>();

            for (int i = 0; i < bags.Count - 1; i++)
            {
                for (int j = i + 1; j < bags.Count; j++)
                {
                    if (bags[i].Type == bags[j].Type)
                    {
                        continue;
                    }
                    double sim = clustering.GetCosineDistance(bags[i], bags[j], true);
                    similars[i, j] = sim;
                    docSimilars.Add(new Tuple <BagOfWords, BagOfWords>(bags[i], bags[j]), sim);
                }
            }

            Console.In.ReadLine();

            OutputSimilarityMatrix(docSimilars);
        }