// Sort and return the least common words (with `count` as max seed count). Also trim punctuation. public static List <string> GetSeeds(this IBrainBackend brain, IList <string> words, int count) { // Make copy for sorting. var copy = new string[words.Count]; words.CopyTo(copy, 0); var wordCounts = brain.WordCount(copy).ToArray(); Array.Sort(wordCounts, copy); var seeds = new List <string>(count); for (int i = 0; i < copy.Length && seeds.Count < count; i++) { if (wordCounts[i] > 0) { string trimmed = copy[i].TrimPunctuation(); if (trimmed.Length >= 1) { seeds.Add(trimmed); } } } return(seeds); }
public BrainFrontend(IBrainBackend brain) { if (brain == null) { throw new ArgumentNullException("brain"); } this.brain = brain; Filter = true; Memory = 100; TimeLimit = TimeSpan.FromSeconds(2); }