public void PopulateTree() { var tree = new CreateBKTree(); tree.Add("help"); tree.Add("hell"); tree.Add("helps"); tree.Add("hello"); tree.Add("shell"); tree.Add("helper"); tree.Add("loop"); tree.Add("toop"); Assert.NotNull(tree); }
static void Main() { string[] dictionary = { "hell", "help", "shel", "smell", "fell", "felt", "oops", "pop", "oouch", "halt" }; CreateBKTree tree = new CreateBKTree(); for (int i = 0; i < dictionary.Length; i++) { tree.Add(dictionary[i]); } const int tolerance = 2; foreach (var match in tree.Match("helt", tolerance)) { Console.WriteLine(match); } }
public void CheckWord() { var tree = new CreateBKTree(); tree.Add("help"); tree.Add("hell"); tree.Add("helps"); tree.Add("hello"); tree.Add("shell"); tree.Add("helper"); tree.Add("loop"); tree.Add("toop"); const string word = "oop"; const int tolerance = 2; var result = new List <string> { "loop", "toop" }; var results = tree.Match(word, tolerance); Assert.Equal(result, results); }
public void CheckAWordWithMultipleSuggestions() { var tree = new CreateBKTree(); tree.Add("help"); tree.Add("hell"); tree.Add("shel"); tree.Add("smell"); tree.Add("fell"); tree.Add("felt"); tree.Add("oops"); tree.Add("pop"); tree.Add("oouch"); tree.Add("halt"); const string word = "helt"; const int tolerance = 2; var result = new List <string> { "help", "shel", "fell", "halt", "felt", "hell" }; var results = tree.Match(word, tolerance); Assert.Equal(result, results); }
public void CheckAnotherWord() { var tree = new CreateBKTree(); tree.Add("help"); tree.Add("hell"); tree.Add("shel"); tree.Add("smell"); tree.Add("fell"); tree.Add("felt"); tree.Add("oops"); tree.Add("pop"); tree.Add("oouch"); tree.Add("halt"); const string word = "ops"; const int tolerance = 3; var result = new List <string> { "oops", "pop" }; var results = tree.Match(word, tolerance); Assert.Equal(result, results); }