public void GetFilteredWords_ShouldReturnCorrectFilteredWords( List <string> text, List <string> expectedResult) { Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory; var result = wordsFilter.GetFilteredWords(text).ToList(); result.Should().HaveSameCount(expectedResult); result.Should().BeEquivalentTo(expectedResult); }
public IEnumerable <TagInfo> TranslateTextToTags( IEnumerable <string> text, HashSet <string> boringWords, string fontFamily, int minFontSize) { minFontSize = Math.Min(120, minFontSize); var normalizedWords = wordsNormalizer.GetNormalizedWords(text, boringWords, hunspell); var filteredWords = wordsFilter.GetFilteredWords(normalizedWords); var frequencies = GetWordsFrequencies(filteredWords); var minFrequency = frequencies.Any() ? frequencies.Min(pair => pair.Value) : 0; foreach (var pair in frequencies) { var fontSize = pair.Value - minFrequency + (int)(minFontSize * 1.15); var font = new Font(fontFamily, fontSize); var value = pair.Key; var rectSize = TextRenderer.MeasureText(value, font); var rect = layouter.PutNextRectangle(rectSize); yield return(new TagInfo(value, font, rect)); } }