Exemple #1
0
        public static Bitmap BuildCloud(IEnumerable <string> lines, int count)
        {
            var frequentWords     = FrequencyAnalyzer.GetFrequencyDict(lines);
            var mostFrequentWords = frequentWords
                                    .OrderByDescending(x => x.Value)
                                    .Take(count)
                                    .ToDictionary(x => x.Key, x => x.Value);

            mostFrequentWords = DictionaryNormalizer.NormalizeDictionary(mostFrequentWords);
            var rects = CloudBilder.CalculateRectsForWords(mostFrequentWords, new Point(0, 0));

            return(CloudDrawer.DrawMap(rects));
        }
Exemple #2
0
            public void ShouldIgnoreCases()
            {
                var lines = new List <string>()
                {
                    "test TEST Test"
                };
                var actulaDict   = FrequencyAnalyzer.GetFrequencyDict(lines, 4);
                var expectedDict = new Dictionary <string, int>()
                {
                    { "TEST", 3 },
                };

                expectedDict.ShouldBeEquivalentTo(actulaDict);
            }
Exemple #3
0
            public void ShouldCountOnlyWordsWithLengthGreaterOrEquallTo()
            {
                var lines = new List <string>()
                {
                    "Some words should be skipped"
                };
                var actulaDict   = FrequencyAnalyzer.GetFrequencyDict(lines, 4);
                var expectedDict = new Dictionary <string, int>()
                {
                    { "SOME", 1 },
                    { "WORDS", 1 },
                    { "SHOULD", 1 },
                    { "SKIPPED", 1 }
                };

                expectedDict.ShouldBeEquivalentTo(actulaDict);
            }