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); } }
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); } }
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; } } }
public bool HasConnection(IngredientNode node) { return connections.Contains<IngredientNode>(node); }
public void AddConnection(IngredientNode node) { connections.Add(node); }
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; } } }
public bool HasConnection(IngredientNode node) { return(connections.Contains <IngredientNode>(node)); }
public void AddConnection(IngredientNode node) { connections.Add(node); }