-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ватлин Алексей #193
base: master
Are you sure you want to change the base?
Ватлин Алексей #193
Conversation
var frequencyDict = text | ||
.Then(w => w | ||
.GroupBy(word => word) | ||
.OrderByDescending(group => group.Count()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Имеет это смысл? Dictionary не гарантирует порядок
text = text.Then(processor.ProcessText); | ||
|
||
var frequencyDict = text | ||
.Then(w => w |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если все через Then делать, то становится менее читаемо. Почему бы тут сразу не посмотреть успешно текст сформирован или нет, и вернуть ошибку.
- Не всегда сообщение в Result = сообщение, которое нужно написать пользователю.
Поэтому я бы предложил, чтобы тут был маппер из внутренних ошибок в ошибки человекочитаемые
foreach (var processor in processors) | ||
text = text.Then(processor.ProcessText); | ||
|
||
var frequencyDict = text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В методы исключения можно вынести
frequencyDict | ||
.Then(dict => | ||
{ | ||
var maxFrequency = dict.Values.Max(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Чтобы не вычислять каждый раз максимальный элемент, можно воспользоваться PriorityQueue<>, SortedList и тд. На свой вкус.
var fontSize = (int)(MIN_FONTSIZE + (float)pair.Value / maxFreq * (MAX_FONTSIZE - MIN_FONTSIZE)); | ||
return new(pair.Key, fontSize); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лишняя строка
".txt" => new TxtFileReader(txtSettings), | ||
".csv" => new CsvFileReader(csvSettings), | ||
".docx" => new WordFileReader(wordSettings), | ||
_ => throw new InvalidOperationException($"Unsupported file extension: {extension}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Исключение. Если введу файл с другим расширением, оно как раз вызовится
|
||
namespace TagsCloudVisualization.Visualizers.ImageColoring; | ||
|
||
public class CustumSingleColoring(Color color) : IImageColoring |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom
stem.StandardInput.Write($"{word}\n"); | ||
var wordInfo = stem.StandardOutput.ReadLine(); | ||
var infoStart = wordInfo.IndexOf("{"); | ||
if (wordInfo is not null && !IsBoring(wordInfo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Проверка на null после того, как переменную уже вызывали
var wordInfo = stem.StandardOutput.ReadLine(); | ||
var infoStart = wordInfo.IndexOf("{"); | ||
if (wordInfo is not null && !IsBoring(wordInfo)) | ||
result.Add(wordInfo.Substring(0, infoStart)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А зачем нам Substring? Мы же не преобразуем никак слово-то. А оно у нас уже есть
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У меня там не совсем слово. То есть мне stem возвращает что-то вроде "Всем{весь=APRO=дат..." и вот всю часть с информацией я отсекаю
[TestFixture] | ||
public class BoringWordsFilterTests | ||
{ | ||
private string path = "./../../../TestData/text.txt"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выстави файл в CopyAlways и будет он у тебя всегда рядом со сборкой
var text = reader.ReadLines(); | ||
var filtered = text.Then(filter.ProcessText); | ||
|
||
filtered.Then(r => r.Should().BeEquivalentTo("Привет", "файл", "должен", "обрабатываться", "корректно")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А для чего мы дальше Result тянем сюда?
почему не просто
filtered.IsSuccess.Should().BeTrue();
filtered.GetValueOrThrow().Should().BeEquivalentTo("Привет", "файл", "должен", "обрабатываться", "корректно");
No description provided.