public static Bitmap BuildCloud(IEnumerable <string> lines, int count) { var frequentWords = FrequencyAnalyzer.GetFrequencyDict(lines); var mostFrequentWords = frequentWords .OrderByDescending(x => x.Value) .Take(count) .ToDictionary(x => x.Key, x => x.Value); mostFrequentWords = DictionaryNormalizer.NormalizeDictionary(mostFrequentWords); var rects = CloudBilder.CalculateRectsForWords(mostFrequentWords, new Point(0, 0)); return(CloudDrawer.DrawMap(rects)); }
static void Main(string[] args) { var count = 0; string destination = null; string source = null; var p = new FluentCommandLineParser(); p.Setup <int>("c", "count").Callback(x => count = x); p.Setup <string>("s", "source").Callback(x => source = x).Required(); p.Setup <string>("d", "destination").Callback(x => destination = x).Required(); p.Parse(args); if (source is null || destination is null) { Console.WriteLine("Destination and source are required"); return; } if (count == 0) { count = 100; Console.WriteLine("Default words count is 100"); } IEnumerable <string> lines; try { lines = File.ReadLines(source); } catch (FileNotFoundException) { Console.WriteLine("File " + source + " not found"); return; } var cloud = CloudBilder.BuildCloud(lines, count); cloud.Save(destination); Console.WriteLine("Saved to " + destination); }