Exemplo n.º 1
0
        public void WordCloudData_EllipsesBetweenWordsTest()
        {
            var text     = "Mmm...mmm...decisions...decisions";
            var expected = new Dictionary <string, int>()
            {
                { "mmm", 2 }, { "decisions", 2 }
            };
            var actual = new WordCloudData(text);

            Assert.Equal(expected, actual.WordsToCounts);
        }
Exemplo n.º 2
0
        public void WordCloudData_SimpleSentenceTest()
        {
            var text     = "I like cake";
            var expected = new Dictionary <string, int>()
            {
                { "I", 1 }, { "like", 1 }, { "cake", 1 }
            };
            var actual = new WordCloudData(text);

            Assert.Equal(expected, actual.WordsToCounts);
        }
Exemplo n.º 3
0
        public void WordCloudData_ApostrophesTest()
        {
            var text     = "Allie's Bakery: Sasha's Cakes";
            var expected = new Dictionary <string, int>()
            {
                { "Bakery", 1 }, { "Cakes", 1 },
                { "Allie's", 1 }, { "Sasha's", 1 }
            };
            var actual = new WordCloudData(text);

            Assert.Equal(expected, actual.WordsToCounts);
        }
Exemplo n.º 4
0
        public void WordCloudData_HyphenatedWordsTest()
        {
            var text     = "Dessert - mille-feuille cake";
            var expected = new Dictionary <string, int>()
            {
                { "cake", 1 }, { "Dessert", 1 },
                { "mille-feuille", 1 }
            };
            var actual = new WordCloudData(text);

            Assert.Equal(expected, actual.WordsToCounts);
        }
Exemplo n.º 5
0
        public void WordCloudData_PunctuationTest()
        {
            var text     = "Strawberry short cake? Yum!";
            var expected = new Dictionary <string, int>()
            {
                { "cake", 1 }, { "Strawberry", 1 },
                { "short", 1 }, { "Yum", 1 }
            };
            var actual = new WordCloudData(text);

            Assert.Equal(expected, actual.WordsToCounts);
        }
Exemplo n.º 6
0
        public void WordCloudData_LongerSentenceTest()
        {
            var text     = "Chocolate cake for dinner and pound cake for dessert";
            var expected = new Dictionary <string, int>()
            {
                { "and", 1 }, { "pound", 1 }, { "for", 2 },
                { "dessert", 1 }, { "Chocolate", 1 }, { "dinner", 1 }, { "cake", 2 }
            };
            var actual = new WordCloudData(text);

            Assert.Equal(expected, actual.WordsToCounts);
        }
Exemplo n.º 7
0
 public async Task AddWords(WordCloudData wordCloudData)
 {
     PopulateWordList(wordCloudData);
     if (_cloudSpace == null)
     {
         Setup();
     }
     try
     {
         await AddWordsInternal();
     }
     catch (OperationCanceledException)
     {
         // If semaphore is canceled catch exception
     }
 }
Exemplo n.º 8
0
        public MainWindow()
        {
            InitializeComponent();

            var wordlist = new List <FrequencyTableRow <WordGroup> >();
            var count    = 0;

            foreach (var kvp in _words.OrderByDescending(x => x.Value))
            {
                wordlist.Add(new FrequencyTableRow <WordGroup>(new WordGroup(kvp.Key), kvp.Value));
                count += kvp.Value;
            }

            Words = new FrequencyTable <WordGroup>(wordlist, count);

            _wordcloudControlDataContext = new WordCloudData(Words);

            WordCloudControl.DataContext = _wordcloudControlDataContext;
        }
Exemplo n.º 9
0
        private void PopulateWordList(WordCloudData wordCloudData)
        {
            var wordList = new List <WordCloudEntry>();

            foreach (var row in wordCloudData.Words.Rows.Take(MaxWords))
            {
                var brushIndex = 0;
                var angle      = 0;

                if (CurrentTheme.BrushList.Count > 1)
                {
                    brushIndex = _randomizer.RandomInt(CurrentTheme.BrushList.Count);
                }

                if (CurrentTheme.WordRotation == WordCloudThemeWordRotation.Mixed)
                {
                    if (wordList.Any() && _randomizer.RandomInt(10) >= 7)
                    {
                        angle = -90;
                    }
                }
                else if (CurrentTheme.WordRotation == WordCloudThemeWordRotation.Random)
                {
                    if (wordList.Any())
                    {
                        angle = -MaxRotation + _randomizer.RandomInt(RangeRotation);
                    }
                }

                // At this stage, the word alpha value is set to be the same as the size value making the word color fade proportionally with word size
                wordList.Add(new WordCloudEntry
                {
                    Word   = row.Item.Word,
                    Weight = row.Count,
                    Brush  = CurrentTheme.BrushList[brushIndex],
                    Angle  = angle
                }
                             );
            }

            _words = wordList.AsReadOnly();
        }