public static List <DateTime> GetSchedule(this Frequency freq, DateTime EndDate, int Depth) { EndDate = freq.Adjust(EndDate, isNext: false); DateTime startDate = freq.Add(EndDate, -Depth); return(freq.GetSchedule(startDate, EndDate, IncludeEndDate: true)); }
public void Handler(string pathFile) { try{ string text = File.ReadAllText(pathFile); string directoryOut = Path.GetDirectoryName(pathFile); string[] words = text.Split(' '); foreach (string word in words) { string uniqueWord = GetUniqueWord(word); if (!NotWords.Contains(uniqueWord)) { if (Frequency.ContainsKey(uniqueWord)) { Frequency[uniqueWord] = Frequency[uniqueWord] + 1; } else { Frequency.Add(uniqueWord, 1); } } } GeneretFile(directoryOut); } catch (Exception exception) { Error = $"Erro durante o processamento: {exception.Message}"; } }
public void Freq_GetScheduleWithDepth() { DateTime startDate = new DateTime(2020, 2, 8); Frequency freq0 = Frequency.Hour1; int n = 32; DateTime endDate = freq0.Add(startDate, n); List <DateTime> schedule1 = freq0.GetSchedule(startDate, endDate); List <DateTime> schedule2 = freq0.GetSchedule(endDate, n); Assert.IsTrue(TestTools <DateTime> .ListComparison(schedule1, schedule2)); }
public override void Explore(string text) { Parallel.ForEach(text, c => { lock (Frequency) { if (!Frequency.ContainsKey(c)) { Frequency.Add(c, 0); } } Frequency[c]++; }); }
public override void Explore(string text) { Frequency.Clear(); if (text.Length == 0) { return; } Parallel.For(0, text.Length - 1, (i, loopStale) => { var key = text.Substring(i, 2); lock (Frequency) { if (!Frequency.ContainsKey(key)) { Frequency.Add(key, 0); } } Frequency[key]++; }); }