public void VerifyPartialRandomInvalidWords() { SuffixTree tree = new SuffixTree(theString); tree.BuildTree(); Random random = new Random((int)DateTime.Now.Ticks); foreach (string individualString in individualStrings) { StringBuilder builder = new StringBuilder(individualString); //this will inject random characters into valid words for (int j = random.Next(individualString.Length - 2); j < random.Next(individualString.Length); j++) { builder.Insert(j, random.Next('a', 'z')); } string builtString = builder.ToString(); string message = "Corrupting: " + individualString + " as " + builtString; //I originally checked to see if builder is in individualStrings, however with such a large //data set it took way too long to execute. There is a risk that a random string of 5 to 15 //characters IS in the word list! if (!individualStrings.Contains(builtString)) { Assert.IsTrue(!tree.Search(builtString), message); } } }
public void VerifyValidWords() { int count = 0; SuffixTree tree = new SuffixTree(theString); tree.BuildTree(); Stopwatch timer = Stopwatch.StartNew(); foreach (string individualString in individualStrings) { Assert.IsTrue(tree.Search(individualString)); count++; } timer.Stop(); Console.WriteLine(count + " words processed in " + timer.ElapsedMilliseconds + " miliseconds."); }
private void TextBox_TextChanged(object sender, EventArgs e) { var count = 0; if (this._suffixTree is null) { return; } _searchResults.Clear(); this._resultTextBox.Text = ""; if (!string.IsNullOrWhiteSpace(_textBox.Text)) { this._searchResults = _suffixTree.Search(_textBox.Text); } foreach (var searchResult in _searchResults) { this._resultTextBox.Text += $"[{++count}] {searchResult}\r\n"; } }
public void VerifyRandomInvalidWords() { SuffixTree tree = new SuffixTree(theString); tree.BuildTree(); Random random = new Random((int)DateTime.Now.Ticks); for (int i = 0; i < individualStrings.Count; i++) { StringBuilder builder = new StringBuilder(); for (int j = 5; j < random.Next(15); j++) { builder.Append(random.Next('a', 'z')); } string builtString = builder.ToString(); string message = "Random String " + builtString + " was found!"; //I originally checked to see if builder is in individualStrings, however with such a large //data set it took way too long to execute. There is a risk that a random string of 5 to 15 //characters IS in the word list! Assert.IsTrue(!tree.Search(builtString)); } }