Esempio n. 1
0
        private static bool SearchExt2(this TwoThreeTree <string> tree, TwoThreeNode <string> node, string value)
        {
            if (node.Val1.CompareTo(value) == 0 || LevenshteinDistance(node.Val1, value) == 1)
            {
                return(true);
            }

            if (node.Val1.CompareTo(value) > 0)
            {
                if (node.Left != null)
                {
                    return(SearchWithOneMistake(tree, node.Left, value));
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                if (node.Right != null)
                {
                    return(SearchWithOneMistake(tree, node.Right, value));
                }
                else
                {
                    return(false);
                }
            }
        }
Esempio n. 2
0
 public void FillDict(string text)
 {
     dictionary = new TwoThreeTree <string>();
     foreach (var word in Regex.Split(text, @"\W+"))
     {
         dictionary.Insert(word);
     }
 }
Esempio n. 3
0
        public static bool SearchWithOneMistake(this TwoThreeTree <string> tree, TwoThreeNode <string> node, string value)
        {
            if (node.Type == NodeType.TwoNode)
            {
                return(SearchExt2(tree, node, value));
            }
            else if (node.Type == NodeType.ThreeNode)
            {
                return(SearchExt3(tree, node, value));
            }

            return(false);
        }