public void Perform() { var dialog = new OpenFileDialog { InitialDirectory = Path.GetFullPath(filePath.WordsFilePath), DefaultExt = "txt", Filter = "Файлы (*.txt)|*.txt" }; var res = dialog.ShowDialog(); if (res != DialogResult.OK) { return; } filePath.WordsFilePath = dialog.FileName; var words = reader.Read(); res = SettingsForm.For(preprocessorSettings).ShowDialog(); if (res != DialogResult.OK) { return; } var preprocessed = preprocessors.Aggregate(words, (current, preprocessor) => preprocessor.Process(current)); var infos = frequencyCounter.CountWordFrequencies(preprocessed); var wordInfos = applicator.GetWordsAndRectangles(infos); painter.Paint(applicator.WordsCenter, wordInfos); imageHolder.UpdateUi(); }
public void BeNotSucceed_WhenWordsAreNull() { var frequencyCounter = new FrequencyCounter(); var resultAction = frequencyCounter.CountWordFrequencies(null); resultAction.IsSuccess.Should().BeFalse(); }
public void CountWordsFrequency() { var frequencyCounter = new FrequencyCounter(); var result = frequencyCounter.CountWordFrequencies(words).GetValueOrThrow(); foreach (var info in result) { var frequency = words.Count(word => word == info.Word); info.Frequency.Should().Be(frequency); } }
public void OrderWordsByFrequency_DyDescending() { var frequencyCounter = new FrequencyCounter(); var result = frequencyCounter.CountWordFrequencies(words).GetValueOrThrow().Select(info => info.Frequency); var previous = int.MaxValue; foreach (var frequency in result) { frequency.Should().BeLessOrEqualTo(previous); previous = frequency; } }