コード例 #1
0
 public void HasWordLookupBenchmark()
 {
     for (int i = 0; i < _words.Length; i++)
     {
         Assert.IsTrue(_trie.HasWord(_words[i]));
     }
 }
コード例 #2
0
 public static void FindWords(ITrie wordTrie)
 {
     for (int i = 0; i < 100; i++)
     {
         foreach (var word in SearchWords)
         {
             wordTrie.HasWord(word);
         }
     }
 }
コード例 #3
0
ファイル: Service.cs プロジェクト: radu-solca/IA_Labs
        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);
        }
コード例 #4
0
        public void HasWord01()
        {
            bool hasWord1 = trie.HasWord("test");

            Assert.IsTrue(hasWord1);
        }