Пример #1
0
        void IndexSubStr(string substr, IngredientNode node)
        {
            var curNode = index.Head;

            for (var i = 0; i < substr.Length; i++)
            {
                var c = substr[i];
                if (curNode.HasLink(c) == false)
                {
                    curNode = curNode.AddLink(c);
                }
                else
                {
                    curNode = curNode.GetLink(c);
                }

                curNode.AddConnection(node);
            }
        }
Пример #2
0
        void IndexSubStr(string substr, IngredientNode node)
        {
            var curNode = index.Head;

             for (var i = 0; i < substr.Length; i++)
             {
            var c = substr[i];
            if (curNode.HasLink(c) == false)
            {
               curNode = curNode.AddLink(c);
            }
            else
            {
               curNode = curNode.GetLink(c);
            }

            curNode.AddConnection(node);
             }
        }
Пример #3
0
        void ParseString(string ing, Guid id)
        {
            var iStart    = 0;
            var iLen      = MIN_SUBSTR;
            var node      = new IngredientNode(id, ing, 0);
            var parsedIng = Regex.Replace(ing.ToLower(), "[^a-z]", "");

            while (iStart + iLen <= parsedIng.Length)
            {
                var substr = parsedIng.Substring(iStart, iLen);
                IndexSubStr(substr, node);
                iLen++;

                if (iStart + iLen > parsedIng.Length)
                {
                    iStart++;
                    iLen = MIN_SUBSTR;
                }
            }
        }
        private void IndexSubstring(string substring, IngredientNode node)
        {
            var currentNode = this.index.Head;

            for (int i = 0; i < substring.Length; i++)
            {
                char character = substring[i];
                if (currentNode.HasLink(character) == false)
                {
                    currentNode = currentNode.AddLink(character);
                }
                else
                {
                    currentNode = currentNode.GetLink(character);
                }

                currentNode.AddConnection(node);
            }
        }
        private void ParseString(string ingredient, Guid id)
        {
            int start = 0;
            int length = MinimumSubstring;
            var node = new IngredientNode(id, ingredient, 0);
            string parsedIngredient = Regex.Replace(ingredient.ToLower(), "[^a-z]", string.Empty);

            while (start + length <= parsedIngredient.Length)
            {
                string substring = parsedIngredient.Substring(start, length);
                this.IndexSubstring(substring, node);
                length++;

                if (start + length > parsedIngredient.Length)
                {
                    start++;
                    length = MinimumSubstring;
                }
            }
        }
Пример #6
0
 public bool HasConnection(IngredientNode node)
 {
     return connections.Contains<IngredientNode>(node);
 }
Пример #7
0
 public void AddConnection(IngredientNode node)
 {
     connections.Add(node);
 }
Пример #8
0
        void ParseString(string ing, Guid id)
        {
            var iStart = 0;
             var iLen = MIN_SUBSTR;
             var node = new IngredientNode(id, ing, 0);
             var parsedIng = Regex.Replace(ing.ToLower(), "[^a-z]", "");

             while (iStart + iLen <= parsedIng.Length)
             {
            var substr = parsedIng.Substring(iStart, iLen);
            IndexSubStr(substr, node);
            iLen++;

            if (iStart + iLen > parsedIng.Length)
            {
               iStart++;
               iLen = MIN_SUBSTR;
            }
             }
        }
Пример #9
0
 public bool HasConnection(IngredientNode node)
 {
     return(connections.Contains <IngredientNode>(node));
 }
Пример #10
0
 public void AddConnection(IngredientNode node)
 {
     connections.Add(node);
 }