-
Notifications
You must be signed in to change notification settings - Fork 303
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
Сибогатов Ринат #204
base: master
Are you sure you want to change the base?
Сибогатов Ринат #204
Conversation
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.
Обратить внимание:
- Заполнение PR (описание, reviewers, assignes, labels)
- Именование веток
- Почитать конвенцию коммитов
- Написать больше тестов
foreach (Section section in document.Sections) | ||
{ | ||
foreach (Paragraph paragraph in section.Paragraphs) | ||
{ | ||
words.AddRange(paragraph.Text.Split(' ', StringSplitOptions.RemoveEmptyEntries)); | ||
} | ||
} |
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.
Как сократить вложенность?
|
||
private Size MeasureTextSize(string text, Font font) | ||
{ | ||
using (var temporaryBitmap = new Bitmap(1, 1)) |
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.
Как поступить с магическими числами? Почему тут 1? Как это понять?
_fontName = fontName; | ||
} | ||
|
||
public void Run(CommandLineOptions options) |
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.
Слишком много ответственности в функции
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.
Следует разбить над подметоды
|
||
var tagCloudImage = GenerateTagCloud(processedWords, options.FontName, fontColor, highlightColor, options.PercentageToHighLight); | ||
|
||
tagCloudImage.Save(@"..\..\..\output\tagsCloud.png"); |
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.
Как с этим быть?
|
||
switch (fileExtension) | ||
{ | ||
case ".doc": |
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.
Что насчёт enum?
} | ||
} | ||
|
||
private Bitmap GenerateTagCloud(IEnumerable<string> words, string fontName, Color fontColor, Color highlightColor, double percentageToHighlight) |
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.
Функция слишком большая
private CircularCloudLayouter CreateLayouter() | ||
{ | ||
var center = new Point(_imageSettings.ImageWidth / 2, _imageSettings.ImageHeight / 2); | ||
var spiral = new Spiral(center, 0.02, 0.04); |
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.
Магические числа
{ | ||
if (wordFrequencies.TryGetValue(word, out var frequency)) | ||
{ | ||
return Math.Max(30, 30 + frequency * 2); |
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.
Магические числа
//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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для чего хранить закомментированный код?
public Point CloudCenter { get; } | ||
public IList<Rectangle> Rectangles { get; } |
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.
Почему решил сделать неполные свойства?
Color BackgroundColor { get; } | ||
Color FontColor { get; } |
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.
Почему решил сделать неполные свойства?
int ImageWidth { get; set; } | ||
int ImageHeight { get; set; } |
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.
Так как это уже элементы интерфейса 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Также и здесь
UpdateSize или SetSize
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.
Не вижу изменений
TagsCloudContainer/Program.cs
Outdated
using (var serviceProvider = Startup.ConfigureServices()) | ||
{ | ||
var tagCloudApp = serviceProvider.GetRequiredService<TagCloudApp>(); | ||
tagCloudApp.Run(o); |
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.
давай поменяем o на что-то длинное и понятное)
|
||
private void ValidateRectangleSize(Size rectangleSize) | ||
{ | ||
if (rectangleSize.Width <= 0 || rectangleSize.Height <= 0) |
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.
для 0 нужно завести константы
|
||
private Point GetUpperLeftCorner(Point rectangleCenter, Size rectangleSize) | ||
{ | ||
return new Point(rectangleCenter.X - rectangleSize.Width / 2, rectangleCenter.Y - rectangleSize.Height / 2); |
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.
для 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тянет на отдельный класс, почитай про 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Дублирование кода, уже где-то выше видел использование деления на 2
int ImageWidth { get; set; } | ||
int ImageHeight { get; set; } | ||
|
||
void UpdateImageSettings(int width, int height); |
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.
Не вижу изменений
|
||
switch (fileExtension) | ||
{ | ||
case ".doc": |
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.
Не вижу изменений
_fontName = fontName; | ||
} | ||
|
||
public void Run(CommandLineOptions options) |
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.
Следует разбить над подметоды
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.
Я бы в README добавил описание зачем они нужны
TagsCloudContainer/Readme.md
Outdated
# TagsCloudContainer | ||
|
||
������ ������������ ����� ��������� ��� ��������� ������ ����� �� ����� � ������� ����. ��������� ������������ �������� ������� ����, �������� ������� ������ � ��������� �����, � ����� ���������� ���� ���� � ������� �������� ��� ����������. | ||
|
||
## ��������� ���������: | ||
|
||
- ��������� ���������������� �������� ������� ����. | ||
- ����������� ���������� ���� ���� � ������� ��������. | ||
- ����������� ��������� ����� ��� ����. | ||
- ����������� ����������� �������� �����, ����, ������. | ||
- �������� CLI. | ||
- ����������� ������: \*.doc, \*.docx, \*.txt. | ||
- ��������� ��������������� ����� ��� ����� ����������������. | ||
- ������� ������ ��������� � �����������. | ||
|
||
## ���������� ���� �� ������ | ||
|
||
- ������ ���� ������� ���� ���������, ��������� � ����� 'boring_words.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.
Слетела кодировка
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.
LGTM 🚀
Описание проекта:
Проект представляет собой программу для генерации облака тегов из файла с набором слов. Программа осуществляет удаление скучных слов, перечень которых указан в отдельном файле, а также приведение всех слов к нижнему регистру для унификации.
Внесенные изменения:
@the-homeless-god