public static void AddToDataTreeBoyerMoore(IDataTree dataTree, string content) { if (dataTree == null || content == null) { throw new ArgumentNullException(); } if (dataTree.GetBaseTree() == null) { throw new InvalidOperationException("Data Tree's base tree cannot be null"); } content = StringFunctions.Normalize(content); if (dataTree is StemmedDocumentMap) { content = StringFunctions.StemmedWord(content); } foreach (Node n in dataTree.GetBaseTree()) { //int matches = content.BoyerMooreMatchCount(n.KeyWord); int matches = content.BoyerMooreMatchCount(" " + n.KeyWord + " "); if (matches > 0) { for (int i = 0; i < matches; i++) { dataTree.AddConnection(n.KeyWord.Trim()); } } } }
public static void AddToDataTree(IDataTree dataTree, string content) { if (dataTree == null || content == null) { throw new ArgumentNullException(); } try { string[] words = content.Split(' '); foreach (string w in words) { dataTree.AddConnection(w); } } catch (NullReferenceException) { throw new InvalidOperationException("Data Tree's base tree cannot be null"); } }
public void AddConnection(string word) { word = StringFunctions.StemmedWord(word); tree.AddConnection(word); }