// Rule 2: Create a new edge and add it to the tree at the parent's position. // Part of this is inserting the new edge into the hash table, // and creating a suffix link to the new node from the last one visited. private void extendSuffixByRuleTwo( ref StSuffix active, StNode parentNode, ref StNode prevParentNode, int endIndex) { StEdge newEdge = new StEdge(this, parentNode, endIndex, this.text.Length - 1); newEdge.Add(); StUtil.WriteLine(StVerbosityLevel.Verbose, String.Format( " Rule #2: New edge E{0:d} (\"{1:s}\") connects N{2:d} (old parent) to N{3:d} (new child)", newEdge.Id, newEdge.GetText(), newEdge.ParentNode.Id, newEdge.ChildNode.Id )); setSuffixLink(prevParentNode, parentNode); prevParentNode = parentNode; }
public StNode Split(StSuffix s) { Remove(); StEdge newEdge = new StEdge(tree, s.OriginNode, BeginIndex, BeginIndex + s.Span); newEdge.Add(); newEdge.ChildNode.SuffixNode = s.OriginNode; BeginIndex += s.Span + 1; ParentNode = newEdge.ChildNode; Add(); StUtil.WriteLine(StVerbosityLevel.Normal, String.Format( " Split E{0:d} into E{1:d} + E{0:d} = \"{2:s}\" + \"{3:s}\"", Id, newEdge.Id, newEdge.GetText(), this.GetText() )); return(newEdge.ChildNode); }
public StNode Split(StSuffix s) { Remove(); StEdge newEdge = new StEdge(tree, s.OriginNode, BeginIndex, BeginIndex + s.Span); newEdge.Add(); newEdge.ChildNode.SuffixNode = s.OriginNode; BeginIndex += s.Span + 1; ParentNode = newEdge.ChildNode; Add(); StUtil.WriteLine(StVerbosityLevel.Normal, String.Format( " Split E{0:d} into E{1:d} + E{0:d} = \"{2:s}\" + \"{3:s}\"", Id, newEdge.Id, newEdge.GetText(), this.GetText() )); return newEdge.ChildNode; }