-
Notifications
You must be signed in to change notification settings - Fork 201
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
Алешев Руслан #176
base: master
Are you sure you want to change the base?
Алешев Руслан #176
Conversation
commandLine = new(); | ||
commandLine.Filename = Path.GetTempFileName(); | ||
commandLine.Output = Path.GetTempFileName(); | ||
//commandLine.FontFamily = "Arial"; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
// Act | ||
var sut = provider.Points().Skip(maxPointsCount-2).First(); | ||
|
||
// Assert |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
return new List<Color>() { Color.White }; | ||
} | ||
|
||
var c = colors.Split(',').Select(x => Color.FromName(x)).ToList(); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
wordFrequency = new Dictionary<string, int>(); | ||
} | ||
|
||
public void Analyze(string text, string exclude = "") |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
{ | ||
if (!File.Exists(excludedWordsPath)) | ||
{ | ||
return; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
var rect = PutNextRectangle(size); | ||
if (!rect.IsSuccess) | ||
{ | ||
yield return Result.Fail<TextImage>("Can't place more rectangles. Try to increase canvas size"); |
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.
Смысл в ленивости: Точки - суть кандидаты для размещения слов. Врят ли имеет смысл вычислять все точки, если нам надо будет разместить лишь пару слов.
public static Result<Image> Draw(Size size, IEnumerable<Result<TextImage>> textImages, Color? bgColor = null) | ||
{ | ||
var image = new Bitmap(size.Width, size.Height); | ||
var gr = Graphics.FromImage(image); |
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.
IDisposable жеж
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.
Класс переименован в Painter, интерфейс реализован.
using TagsCloudVisualization; | ||
using TagsCloudContainer.TagCloudBuilder; | ||
|
||
namespace ResutlTests |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
layouter.Initialize(appSettings.DrawingSettings, analyzer.GetAnalyzedText()); | ||
|
||
Visualizer.Draw(appSettings.DrawingSettings.Size, |
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 и Then
что-то типа, должен получиться лаконичный пайплайн обработки:
var res = fileReaderFactory
.Create(settings.InputPath)
.Then(fileReader=> fileReader.GetLines(settings.InputPath))
.Then(lemmatizer.GetLemmas)
.Then(filter.FilterWords)
.Then(weigher.GetWeightedWords)
.Then(painter.CreateImage)
.Then(bitmap => saver.Save(bitmap, settings.OutputPath, settings.OutputFormat));
if (!res.IsSuccess)
Console.Write(res.Error);
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 (IsSuccess) return Value; | ||
|
||
ErrorParser.Critical(Error); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
var rawText = TextFileReader.ReadText(appSettings.TextFile); | ||
if (rawText.IsSuccess) | ||
{ | ||
var res = FrequencyAnalyzer.Analyze(rawText.GetValueOrDefault(), appSettings.FilterFile) |
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.
RawText можно тож через Then передавать же, не?
Тебе просто нужен Then
public static Result<TOutput> Then<TInput, TOutput>(this Result<TInput> input, Func<TInput, Result<TOutput>> continuation)
{
return input.IsSuccess && input.Value != null
? continuation(input.Value)
: Fail<TOutput>(input.Error);
}
Суть - не кидаешь эксепшоны, складываешь в монаду ошибки, так тебе не понадобится GetValueOrDefault() и тд
@grantsev
Задание TagsCloudResult