Conversation
the-homeless-god
left a comment
There was a problem hiding this comment.
Обратить внимание:
- Заполнение PR (описание, reviewers, assignes, labels)
- Именование веток
- Почитать конвенцию коммитов
- Написать больше тестов
| foreach (Section section in document.Sections) | ||
| { | ||
| foreach (Paragraph paragraph in section.Paragraphs) | ||
| { | ||
| words.AddRange(paragraph.Text.Split(' ', StringSplitOptions.RemoveEmptyEntries)); | ||
| } | ||
| } |
|
|
||
| private Size MeasureTextSize(string text, Font font) | ||
| { | ||
| using (var temporaryBitmap = new Bitmap(1, 1)) |
There was a problem hiding this comment.
Как поступить с магическими числами? Почему тут 1? Как это понять?
| _fontName = fontName; | ||
| } | ||
|
|
||
| public void Run(CommandLineOptions options) |
There was a problem hiding this comment.
Слишком много ответственности в функции
|
|
||
| var tagCloudImage = GenerateTagCloud(processedWords, options.FontName, fontColor, highlightColor, options.PercentageToHighLight); | ||
|
|
||
| tagCloudImage.Save(@"..\..\..\output\tagsCloud.png"); |
|
|
||
| switch (fileExtension) | ||
| { | ||
| case ".doc": |
| } | ||
| } | ||
|
|
||
| private Bitmap GenerateTagCloud(IEnumerable<string> words, string fontName, Color fontColor, Color highlightColor, double percentageToHighlight) |
| private CircularCloudLayouter CreateLayouter() | ||
| { | ||
| var center = new Point(_imageSettings.ImageWidth / 2, _imageSettings.ImageHeight / 2); | ||
| var spiral = new Spiral(center, 0.02, 0.04); |
| { | ||
| if (wordFrequencies.TryGetValue(word, out var frequency)) | ||
| { | ||
| return Math.Max(30, 30 + frequency * 2); |
| //private static void DrawRectangles(IEnumerable<Rectangle> rectangles, Graphics graphics) | ||
| //{ | ||
| // var pen = new Pen(Color.Green); | ||
| // foreach (var rect in rectangles) | ||
| // { | ||
| // graphics.DrawRectangle(pen, rect); | ||
| // } | ||
| //} |
There was a problem hiding this comment.
Для чего хранить закомментированный код?
| public Point CloudCenter { get; } | ||
| public IList<Rectangle> Rectangles { get; } |
There was a problem hiding this comment.
Почему решил сделать неполные свойства?
| Color BackgroundColor { get; } | ||
| Color FontColor { get; } |
There was a problem hiding this comment.
Почему решил сделать неполные свойства?
| int ImageWidth { get; set; } | ||
| int ImageHeight { get; set; } |
There was a problem hiding this comment.
Так как это уже элементы интерфейса Image, то можно опустить слова Image
То есть:
Width
Height
| int ImageWidth { get; set; } | ||
| int ImageHeight { get; set; } | ||
|
|
||
| void UpdateImageSettings(int width, int height); |
There was a problem hiding this comment.
Также и здесь
UpdateSize или SetSize
TagsCloudContainer/Program.cs
Outdated
| using (var serviceProvider = Startup.ConfigureServices()) | ||
| { | ||
| var tagCloudApp = serviceProvider.GetRequiredService<TagCloudApp>(); | ||
| tagCloudApp.Run(o); |
There was a problem hiding this comment.
давай поменяем o на что-то длинное и понятное)
|
|
||
| private void ValidateRectangleSize(Size rectangleSize) | ||
| { | ||
| if (rectangleSize.Width <= 0 || rectangleSize.Height <= 0) |
There was a problem hiding this comment.
для 0 нужно завести константы
|
|
||
| private Point GetUpperLeftCorner(Point rectangleCenter, Size rectangleSize) | ||
| { | ||
| return new Point(rectangleCenter.X - rectangleSize.Width / 2, rectangleCenter.Y - rectangleSize.Height / 2); |
| /// Расчитывает размер шрифта для заданного слова на основе его частоты встречаемости. | ||
| /// </summary> | ||
| /// <param name="word">Строка, представляющая слово, для которого необходимо определить размер шрифта.</param> | ||
| /// <param name="wordFrequencies">Словарь, содержащий частоту встречаемости каждого слова в тексте.</param> | ||
| /// <returns>Размер шрифта для заданного слова.</returns> | ||
|
|
||
| private const int BaseFontSize = 30; | ||
| private const int FontSizeMultiplier = 2; | ||
| private const int DefaultFontSize = 10; | ||
| private int CalculateWordFontSize(string word, Dictionary<string, int> wordFrequencies) | ||
| { | ||
| if (wordFrequencies.TryGetValue(word, out var frequency)) | ||
| { | ||
| return Math.Max(BaseFontSize, BaseFontSize + frequency * FontSizeMultiplier); | ||
| } | ||
| return DefaultFontSize; | ||
| } | ||
|
|
||
|
|
||
| private Dictionary<string, int> CalculateWordFrequencies(IEnumerable<string> words) | ||
| { | ||
| var wordFrequencies = new Dictionary<string, int>(); | ||
|
|
||
| foreach (var word in words) | ||
| { | ||
| wordFrequencies.TryGetValue(word, out var frequency); | ||
| wordFrequencies[word] = frequency + 1; | ||
| } | ||
|
|
||
| return wordFrequencies; |
There was a problem hiding this comment.
Тянет на отдельный класс, почитай про S в SOLID
|
|
||
| private CircularCloudLayouter CreateLayouter(double angleStep = DefaultAngleStep, double radiusStep = DefaultRadiusStep) | ||
| { | ||
| var center = new Point(_imageSettings.ImageWidth / 2, _imageSettings.ImageHeight / 2); |
There was a problem hiding this comment.
Дублирование кода, уже где-то выше видел использование деления на 2
| int ImageWidth { get; set; } | ||
| int ImageHeight { get; set; } | ||
|
|
||
| void UpdateImageSettings(int width, int height); |
|
|
||
| switch (fileExtension) | ||
| { | ||
| case ".doc": |
| _fontName = fontName; | ||
| } | ||
|
|
||
| public void Run(CommandLineOptions options) |
There was a problem hiding this comment.
Я бы в README добавил описание зачем они нужны
TagsCloudContainer/Readme.md
Outdated
| # TagsCloudContainer | ||
|
|
||
| ������ ������������ ����� ��������� ��� ��������� ������ ����� �� ����� � ������� ����. ��������� ������������ �������� ������� ����, �������� ������� ������ � ��������� �����, � ����� ���������� ���� ���� � ������� �������� ��� ����������. | ||
|
|
||
| ## ��������� ���������: | ||
|
|
||
| - ��������� ���������������� �������� ������� ����. | ||
| - ����������� ���������� ���� ���� � ������� ��������. | ||
| - ����������� ��������� ����� ��� ����. | ||
| - ����������� ����������� �������� �����, ����, ������. | ||
| - �������� CLI. | ||
| - ����������� ������: \*.doc, \*.docx, \*.txt. | ||
| - ��������� ��������������� ����� ��� ����� ����������������. | ||
| - ������� ������ ��������� � �����������. | ||
|
|
||
| ## ���������� ���� �� ������ | ||
|
|
||
| - ������ ���� ������� ���� ���������, ��������� � ����� 'boring_words.txt' No newline at end of file |
Описание проекта:
Проект представляет собой программу для генерации облака тегов из файла с набором слов. Программа осуществляет удаление скучных слов, перечень которых указан в отдельном файле, а также приведение всех слов к нижнему регистру для унификации.
Внесенные изменения:
@the-homeless-god