-
Notifications
You must be signed in to change notification settings - Fork 32
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
Сахабутдинов Ильфир #10
Open
ILFirV-V
wants to merge
46
commits into
kontur-courses:master
Choose a base branch
from
ILFirV-V:request-branch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 40 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
fcfef16
Add. Созданы проекты для работы
abccc22
Add. Тесты на анализатор размеров слов
6949841
Add. Тесты на CircularCloudLayouter
01469e5
Add. Модели для работы с визуализацией слов
7506f8c
Add. Провайдер для доставки и изменения настроек визуализации
11a771c
Add. Логика визуализации слов
875b3e7
Add. Модели для анализа текста
9799764
Add. Провайдер для изменения настроек анализа слов
374e8b8
Add. Логика анализа текста
cc2d9ec
Add. Options консольного клиента
b280405
Add. Обработчики команд для консольного клиента
3cf4786
Add. Реализация консольного цикла UI
b036085
Add. DI консольного клиента
3d0f01e
Fix. Убрал локальный путь к MyStem
6555faf
Add. Тесты для проекта "TextAnalyzer"
b7d1f84
Update. Изменены тесты для класса "CircularCloudLayouter"
dafbd1f
Update. Изменены тесты для класса "WeigherWordSizer"
12d3867
Add. Добавлены тесты для класса "LayoutCreator"
576342e
Add. Добавлены тесты для класса "SpiralPlacementStrategy"
ed52137
Update. Проект "TextAnalyzer" переведен с Autofac на Microsoft Depend…
89a8163
Add. Добавлены внешние ресурсы
0c30b05
Update. Изменен уровень доступа модели для тестирования
a518a02
Update. В проекте "TextAnalyzer" убраны неиспользуемые методы
811186a
Fix. Исправлена ошибка с сохранением только уникальных слов
168c4bb
Update. Проект "TagsCloudVisualization" переведен с Autofac на Micros…
5bf1148
Add. Добавлены настройки путей к исходному и конечному файлам
0218dcb
Add. Добавлен создатель "Layouter" для получения нового экземпляра пр…
f90b190
Update. Разделение ответственности. Выделены функции для получения ло…
17995b9
Fix. Убрана лишняя проверка на null
3dbbf15
Update. Переделана регистрация в di сервисов из библиотек
33ff049
Update. Изменены опции для отдельной работы с настройками и генерацией
73fa95a
Update. Изменены обработчики.
beb0653
Update. Обработка команд заменена на использование специализированных…
f8138dd
Update. Регистрация обработчиков и опций в di
a956e96
Update. Переход на net8.0-windows для зависимостей, специфичных для W…
2afad1f
Fix. Правки проверок изменений опций для настроек в консольном клиенте
0ca0484
Fix. Небольшие исправления после инспекции кода связанные с чистотой …
3bf28fa
Fix. Правки связанные с пробелами и отступами
fcacd8e
Add. Более подробное описание опции в `HelpText`
3e9a479
Add. Примеры и мануал
2cdc617
Update. Конфигурирование через параметры запуска
95ed38d
Fix. Поправка жизненного цикла сервиса
bee0e72
Fix. Удаление ненужного вызова .ToList()
c63a0bb
Fix. Форматирование стиля кода (добавление пробелов)
ce3021e
Fix. Удаление папки Logic из ItemGroup
99843fc
Add. Добавлены тесты, проверяющие работу всей программы в сборке
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Autofac; | ||
using TagsCloudContainer.ConsoleUi.Handlers; | ||
using TagsCloudContainer.ConsoleUi.Handlers.Interfaces; | ||
using TagsCloudContainer.ConsoleUi.Options; | ||
using TagsCloudContainer.ConsoleUi.Options.Interfaces; | ||
using TagsCloudContainer.ConsoleUi.Runner; | ||
using TagsCloudContainer.ConsoleUi.Runner.Interfaces; | ||
|
||
namespace TagsCloudContainer.ConsoleUi; | ||
|
||
public class ConsoleClientModule : Module | ||
{ | ||
protected override void Load(ContainerBuilder builder) | ||
{ | ||
builder.RegisterType<TagsCloudContainerUi>().As<ITagsCloudContainerUi>(); | ||
builder.RegisterType<ExitHandler>().As<IHandler<ExitOptions>>(); | ||
builder.RegisterType<WordSettingsHandler>().As<IHandler<WordSettingsOptions>>(); | ||
builder.RegisterType<ImageSettingHandler>().As<IHandler<ImageSettingsOptions>>(); | ||
builder.RegisterType<FileSettingsHandler>().As<IHandler<FileSettingsOptions>>(); | ||
builder.RegisterType<GenerationHandler>().As<IHandler<GenerationOptions>>(); | ||
builder.RegisterType<ExitOptions>().As<IOptions>(); | ||
builder.RegisterType<GenerationOptions>().As<IOptions>(); | ||
builder.RegisterType<ImageSettingsOptions>().As<IOptions>(); | ||
builder.RegisterType<FileSettingsOptions>().As<IOptions>(); | ||
builder.RegisterType<WordSettingsOptions>().As<IOptions>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
Задание | ||
TagsCloudContainer | ||
Сделай | ||
fork | ||
этого | ||
и | ||
работай | ||
в | ||
нем. | ||
Нужно | ||
сделать | ||
приложение | ||
генератора | ||
облака | ||
слов | ||
по | ||
произвольному | ||
тексту. | ||
Примеры. | ||
В | ||
облаке | ||
не | ||
должно | ||
быть | ||
повторяющихся | ||
слов, | ||
размер | ||
слова | ||
должен | ||
быть | ||
тем | ||
больше, | ||
чем | ||
чаще | ||
встречается | ||
слово, | ||
не | ||
должно | ||
быть | ||
"скучных" | ||
слов | ||
(предлогов, | ||
местоимений, | ||
Используй | ||
алгоритм | ||
из | ||
блока | ||
про | ||
TDD. | ||
Ограничения | ||
Точки | ||
расширения | ||
В | ||
промышленном | ||
программировании | ||
при | ||
разработке | ||
далеко | ||
не | ||
всегда | ||
разумно | ||
создавать | ||
точки | ||
расширения | ||
Чаще | ||
руководствуются | ||
принципами | ||
YAGNI | ||
KISS, | ||
поддерживая | ||
код | ||
как | ||
можно | ||
проще, | ||
а | ||
абстракции | ||
создаются | ||
и | ||
внедряются | ||
в | ||
код | ||
только | ||
в | ||
момент, | ||
когда | ||
понадобилось | ||
расширить | ||
функциональность. | ||
Тем | ||
не | ||
менее | ||
для | ||
учебных | ||
целей | ||
в | ||
этой | ||
задаче | ||
требуется | ||
заранее | ||
предусмотреть | ||
точки | ||
расширения | ||
для | ||
наиболее | ||
вероятных | ||
потенциальных | ||
изменений | ||
в | ||
твоем | ||
продукте. | ||
Результат | ||
твоей | ||
работы | ||
должен | ||
быть | ||
расширяем | ||
без | ||
модификации | ||
уже | ||
имеющегося | ||
кода | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using TagsCloudContainer.ConsoleUi.Handlers.Interfaces; | ||
using TagsCloudContainer.ConsoleUi.Options; | ||
|
||
namespace TagsCloudContainer.ConsoleUi.Handlers; | ||
|
||
public class ExitHandler : IHandler<ExitOptions> | ||
{ | ||
public string Execute(ExitOptions options) | ||
{ | ||
Environment.Exit(0); | ||
return "Завершение"; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
TagsCloudContainer.ConsoleUi/Handlers/FileSettingsHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using TagsCloudContainer.ConsoleUi.Handlers.Interfaces; | ||
using TagsCloudContainer.ConsoleUi.Options; | ||
using TagsCloudContainer.TagsCloudVisualization.Providers.Interfaces; | ||
|
||
namespace TagsCloudContainer.ConsoleUi.Handlers; | ||
|
||
public class FileSettingsHandler(IFileSettingsProvider settingsProvider) | ||
: IHandler<FileSettingsOptions> | ||
{ | ||
public string Execute(FileSettingsOptions settingsOptions) | ||
{ | ||
SetFileSettings(settingsOptions); | ||
return "Настройки изменены"; | ||
} | ||
|
||
private void SetFileSettings(FileSettingsOptions settingsOptions) | ||
{ | ||
var currentSettings = settingsProvider.GetPathSettings(); | ||
if (!string.IsNullOrEmpty(settingsOptions.ImageFormatString) && | ||
!Equals(settingsOptions.ImageFormat, currentSettings.ImageFormat)) | ||
{ | ||
settingsProvider.SetImageFormat(settingsOptions.ImageFormat); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(settingsOptions.InputPath) | ||
&& !Equals(settingsOptions.InputPath, currentSettings.InputPath)) | ||
{ | ||
settingsProvider.SetInputPath(settingsOptions.InputPath); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(settingsOptions.OutputPath) | ||
&& !Equals(settingsOptions.OutputPath, currentSettings.OutputPath)) | ||
{ | ||
settingsProvider.SetOutputPath(settingsOptions.OutputPath); | ||
} | ||
|
||
if (!string.IsNullOrEmpty(settingsOptions.OutputFileName) && | ||
!Equals(settingsOptions.OutputFileName, currentSettings.OutputFileName)) | ||
{ | ||
settingsProvider.SetOutputFileName(settingsOptions.OutputFileName); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
TagsCloudContainer.ConsoleUi/Handlers/GenerationHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using TagsCloudContainer.ConsoleUi.Handlers.Interfaces; | ||
using TagsCloudContainer.ConsoleUi.Options; | ||
using TagsCloudContainer.TagsCloudVisualization.Logic.Visualizers.Interfaces; | ||
using TagsCloudContainer.TagsCloudVisualization.Providers.Interfaces; | ||
using TagsCloudContainer.TextAnalyzer.Logic.Preprocessors.Interfaces; | ||
using TagsCloudContainer.TextAnalyzer.Logic.Readers.Interfaces; | ||
using TagsCloudContainer.TextAnalyzer.Providers.Interfaces; | ||
|
||
namespace TagsCloudContainer.ConsoleUi.Handlers; | ||
|
||
public class GenerationHandler( | ||
IFileTextReader fileReader, | ||
ITextPreprocessor textPreprocessor, | ||
IWordsCloudVisualizer wordsCloudVisualizer, | ||
IFileSettingsProvider fileSettingsProvider, | ||
IImageSettingsProvider imageSettingsProvider, | ||
IWordSettingsProvider wordSettingsProvider) | ||
: IHandler<GenerationOptions> | ||
{ | ||
public string Execute(GenerationOptions options) | ||
{ | ||
GenerateFile(); | ||
return "Сгенерирован файл"; | ||
} | ||
|
||
private void GenerateFile() | ||
{ | ||
var pathSettings = fileSettingsProvider.GetPathSettings(); | ||
var imageSettings = imageSettingsProvider.GetImageSettings(); | ||
var wordSettings = wordSettingsProvider.GetWordSettings(); | ||
var text = fileReader.ReadText(pathSettings.InputPath); | ||
var analyzeWords = textPreprocessor.GetWordFrequencies(text, wordSettings); | ||
using var image = wordsCloudVisualizer.CreateImage(imageSettings, analyzeWords); | ||
wordsCloudVisualizer.SaveImage(image, pathSettings); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
TagsCloudContainer.ConsoleUi/Handlers/ImageSettingHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using TagsCloudContainer.ConsoleUi.Handlers.Interfaces; | ||
using TagsCloudContainer.ConsoleUi.Options; | ||
using TagsCloudContainer.TagsCloudVisualization.Providers.Interfaces; | ||
|
||
namespace TagsCloudContainer.ConsoleUi.Handlers; | ||
|
||
public class ImageSettingHandler(IImageSettingsProvider imageSettingsProvider) : IHandler<ImageSettingsOptions> | ||
{ | ||
public string Execute(ImageSettingsOptions options) | ||
{ | ||
SetSettings(options); | ||
return "Настройки изображения изменены"; | ||
} | ||
|
||
private void SetSettings(ImageSettingsOptions options) | ||
{ | ||
var currentSettings = imageSettingsProvider.GetImageSettings(); | ||
if (options.BackgroundColor != default && !options.BackgroundColor.Equals(currentSettings.BackgroundColor)) | ||
{ | ||
imageSettingsProvider.SetBackgroundColor(options.BackgroundColor); | ||
} | ||
|
||
if (options.WordColor != default && !options.WordColor.Equals(currentSettings.WordColor)) | ||
{ | ||
imageSettingsProvider.SetWordColor(options.WordColor); | ||
} | ||
|
||
if (options.FontFamily is not null && !Equals(options.FontFamily, currentSettings.FontFamily)) | ||
{ | ||
imageSettingsProvider.SetFontFamily(options.FontFamily); | ||
} | ||
|
||
if (options.Height != default && !options.Height.Equals(currentSettings.Size.Height)) | ||
{ | ||
var newSize = currentSettings.Size with { Height = options.Height }; | ||
imageSettingsProvider.SetSize(newSize); | ||
} | ||
|
||
if (options.Width != default && !options.Width.Equals(currentSettings.Size.Width)) | ||
{ | ||
var newSize = currentSettings.Size with { Width = options.Width }; | ||
imageSettingsProvider.SetSize(newSize); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using TagsCloudContainer.ConsoleUi.Options.Interfaces; | ||
|
||
namespace TagsCloudContainer.ConsoleUi.Handlers.Interfaces; | ||
|
||
public interface IHandler<in TOptions> | ||
where TOptions : IOptions | ||
{ | ||
public string Execute(TOptions options); | ||
} |
24 changes: 24 additions & 0 deletions
24
TagsCloudContainer.ConsoleUi/Handlers/WordSettingsHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using TagsCloudContainer.ConsoleUi.Handlers.Interfaces; | ||
using TagsCloudContainer.ConsoleUi.Options; | ||
using TagsCloudContainer.TextAnalyzer.Providers.Interfaces; | ||
|
||
namespace TagsCloudContainer.ConsoleUi.Handlers; | ||
|
||
public class WordSettingsHandler(IWordSettingsProvider wordSettingsProvider) : IHandler<WordSettingsOptions> | ||
{ | ||
public string Execute(WordSettingsOptions options) | ||
{ | ||
SetSettings(options); | ||
return "Настройки изображения изменены"; | ||
} | ||
|
||
private void SetSettings(WordSettingsOptions options) | ||
{ | ||
var currentSettings = wordSettingsProvider.GetWordSettings(); | ||
if (options.ValidSpeechParts.Count != 0 | ||
&& !options.ValidSpeechParts.SequenceEqual(currentSettings.ValidSpeechParts)) | ||
{ | ||
wordSettingsProvider.SetValidSpeechParts(options.ValidSpeechParts); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using CommandLine; | ||
using TagsCloudContainer.ConsoleUi.Options.Interfaces; | ||
|
||
namespace TagsCloudContainer.ConsoleUi.Options; | ||
|
||
[Verb("exit", HelpText = "Выйти")] | ||
public class ExitOptions : IOptions | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Drawing.Imaging; | ||
using CommandLine; | ||
using TagsCloudContainer.ConsoleUi.Options.Interfaces; | ||
|
||
namespace TagsCloudContainer.ConsoleUi.Options; | ||
|
||
[Verb("files", HelpText = "Настройки путей файлов")] | ||
public class FileSettingsOptions : IOptions | ||
{ | ||
[Option('i', "input", Required = true, HelpText = "Путь к файлу текста для анализа.")] | ||
public string InputPath { get; set; } | ||
|
||
[Option('o', "output", Required = true, HelpText = "Путь к сохранению изображения.")] | ||
public string OutputPath { get; set; } | ||
|
||
[Option('n', "name", Required = true, HelpText = "Имя файла")] | ||
public string OutputFileName { get; set; } | ||
|
||
[Option('f', "format", HelpText = "Формат файла (png, jpeg, bmp, jpg.)")] | ||
public string ImageFormatString { get; set; } | ||
|
||
public ImageFormat ImageFormat | ||
{ | ||
get | ||
{ | ||
return ImageFormatString.ToLower() switch | ||
{ | ||
"png" => ImageFormat.Png, | ||
"jpg" => ImageFormat.Jpeg, | ||
"jpeg" => ImageFormat.Jpeg, | ||
"bmp" => ImageFormat.Bmp, | ||
_ => throw new ArgumentException($"Unsupported image format: {ImageFormatString}") | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using CommandLine; | ||
using TagsCloudContainer.ConsoleUi.Options.Interfaces; | ||
|
||
namespace TagsCloudContainer.ConsoleUi.Options; | ||
|
||
[Verb("generate", HelpText = "Сгенерировать изображение")] | ||
public class GenerationOptions : IOptions | ||
{ | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Добавил