public void AddWord_EmptyString01() { trie = new Trie(); Assert.AreEqual(0, trie.GetWords().Count); trie.AddWord(""); Assert.AreNotEqual(0, trie.GetWords().Count); }
public static void Main(string[] args) { // Trie implementation from https://github.com/rmandvikar/csharp-trie Console.WriteLine("The program read all words from 'text.txt',"); Console.WriteLine("adds them in a Trie and prnt the first 1000 words"); Console.WriteLine("along with the occurrences of each word"); Console.WriteLine("Press any key to begin.."); Console.ReadKey(); ITrie trie = TrieFactory.CreateTrie(); var reader = new StreamReader("../../text.txt"); ReadWordsFromText(reader, trie); var counter = 0; foreach (var currentWord in trie.GetWords()) { counter++; if (counter == 1000) { break; } var wordCounter = trie.WordCount(currentWord); Console.WriteLine("{0} - {1}", currentWord, wordCounter); } }
public void TrieLookupBenchmark() { var words = new List <string>(); for (int i = 0; i < _prefixes.Length; i++) { words.AddRange(_trie.GetWords(_prefixes[i])); } Assert.IsNotEmpty(words); }
public void Getlist(string source) { IEnumerable<string> temp = trie.GetWords(source); int i = 0; foreach (string ss in temp) { if (i >= 5) break; BNRefine.central[i++] = ss; } }
public static int Fitness(List <char> individual, ITrie dictionary, string encryptedSentence) { int fitness = 1; string decryptedSentence = Encrypt(encryptedSentence, individual); string prefix = ""; foreach (var character in decryptedSentence) { prefix += character; if (dictionary.HasWord(prefix)) // prefix is a word in our dictionary { fitness += prefix.Length; } while (dictionary.GetWords(prefix).Count == 0) // no words with this prefix { prefix = prefix.Substring(1); // remove first character from prefix; } } return(fitness); }
public void GetWords01() { var words = trie.GetWords(); Assert.AreEqual(10, words.Count); }