static void BuildStandardTrie() { standard = new Trie () { Character = '\0', Length = 0 }; foreach (string word in File.ReadLines ("/usr/share/dict/american-english")) { if (word.Length > 1 || word == "a" || word == "I") standard.Insert (word); } }
public void Insert(string s) { var t = this; foreach (var character in s) { var next = t.Next (character); if (next == null) { next = new Trie () { Character = character, Length = t.Length + 1 }; if (t.Children == null) t.Children = new List<Trie> (); t.Children.Add (next); } t = next; } t.Word = s; }