示例#1
0
        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);
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }