/// <summary> /// Words to train the auto-complete engine on. /// </summary> /// <param name="passage">text that is processed to enhance predictions.</param> /// <param name="removePunctuation">removes punctuation before processing</param> /// <param name="caseSensitive">predicts words with case sensitivity</param> public void Train(string passage, bool removePunctuation = true, bool caseSensitive = false) { if (removePunctuation) { passage = _RemovePunctuation(passage); } var words = passage.Split(null /* whitespace */) .Where(word => !string.IsNullOrWhiteSpace(word)) .Select(word => { var modified = word; modified = word.Trim(); if (!caseSensitive) { modified = modified.ToLowerInvariant(); } return(_NodeFactory.CreateNode(modified, modified)); }); _Trie.AddRange(words); }