-
Notifications
You must be signed in to change notification settings - Fork 295
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (31 loc) · 1.42 KB
/
Program.cs
File metadata and controls
39 lines (31 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using CommandLine;
using Microsoft.Extensions.DependencyInjection;
using TagsCloudContainer.CLI;
using TagsCloudContainer.Drawer;
using TagsCloudContainer.FrequencyAnalyzers;
using TagsCloudContainer.SettingsClasses;
using TagsCloudContainer.TextTools;
using TagsCloudVisualization;
namespace TagsCloudContainer
{
public static class Program
{
public static void Main(string[] args)
{
var services = DependencyInjectionConfig.AddCustomServices(new ServiceCollection());
var serviceProvider = services.BuildServiceProvider();
var reader = serviceProvider.GetService<ITextReader>();
var analyzer = serviceProvider.GetService<IAnalyzer>();
var appSettings = new AppSettings();
Parser.Default.ParseArguments<CommandLineOptions>(args)
.WithParsed(o => appSettings = CommandLineOptions.ParseArgs(o));
var text = reader.ReadText(appSettings.TextFile);
var layouter = serviceProvider.GetService<TagsCloudLayouter>();
analyzer.Analyze(text, appSettings.FilterFile);
layouter.Initialize(appSettings.DrawingSettings, analyzer.GetAnalyzedText());
Visualizer.Draw(appSettings.DrawingSettings.Size,
layouter.GetTextImages()).Save(appSettings.OutImagePath);
Console.WriteLine("Resulting image saved to " + appSettings.OutImagePath);
}
}
}