コード例 #1
0
        public void BurstTrie_SortEnglish2Grams()
        {
            System.Console.Out.WriteLine("Total possibly duplicated words in input: " + _grams.Length);

            string[]  strings = _grams;
            BurstTrie trie    = new BurstTrie();

            foreach (string s in strings)
            {
                trie.Add(s);
            }

            List <string> sorted = trie.GetAllEntries();

            System.Console.Out.WriteLine("Words found through reconstruction: " + sorted.Count);

            //Dictionary<string, int> uniques = new Dictionary<string, int>();
            //foreach (string s in sorted)
            //    if (!uniques.ContainsKey(s))
            //        uniques.Add(s, 1);
            //    else
            //        uniques[s] = uniques[s] + 1;

            //System.Console.Out.WriteLine("unique words found: " + uniques.Keys.Count);
        }
コード例 #2
0
        public void BurstTrie_ReconstructOrdered()
        {
            BurstTrie trie = new BurstTrie();

            trie.Add("d");
            trie.Add("de");
            trie.Add("abcd");
            trie.Add("bce");
            trie.Add("0000000");
            trie.Add("def");
            trie.Add("abc");
            trie.Add("0000001");
            trie.Add("cde");
            trie.Add("0a");
            trie.Add("cd");
            trie.Add("bced");

            List <string> allEntries = trie.GetAllEntries();

            Assert.IsTrue(allEntries[0].Equals("0000000"));
            Assert.IsTrue(allEntries[1].Equals("0000001"));
            Assert.IsTrue(allEntries[2].Equals("0a"));
            Assert.IsTrue(allEntries[3].Equals("abc"));
            Assert.IsTrue(allEntries[4].Equals("abcd"));
            Assert.IsTrue(allEntries[5].Equals("bce"));
            Assert.IsTrue(allEntries[6].Equals("bced"));
            Assert.IsTrue(allEntries[7].Equals("cd"));
            Assert.IsTrue(allEntries[8].Equals("cde"));
            Assert.IsTrue(allEntries[9].Equals("d"));
            Assert.IsTrue(allEntries[10].Equals("de"));
            Assert.IsTrue(allEntries[11].Equals("def"));
        }
コード例 #3
0
        public void BurstTrie_ReconstructSimple()
        {
            BurstTrie trie = new BurstTrie();
            string    s    = "cat";

            trie.Add(s);
            List <string> all = trie.GetAllEntries();

            Assert.IsTrue(all.Contains(s));
        }
コード例 #4
0
        protected void VerifyPresence(BurstTrie trie, List <string> items)
        {
            List <string> allEntries = trie.GetAllEntries();

            Assert.AreEqual(allEntries.Count, items.Count);

            foreach (string s in items)
            {
                Assert.IsTrue(allEntries.Contains(s));
            }
        }
コード例 #5
0
        public void BurstTrie_ReconstructDuplicates()
        {
            BurstTrie trie = new BurstTrie();

            trie.Add("0000000");
            trie.Add("0000001");
            trie.Add("0000000");

            List <string> allEntries = trie.GetAllEntries();

            Assert.IsTrue(allEntries[0].Equals("0000000"));
            Assert.IsTrue(allEntries[1].Equals("0000000"));
            Assert.IsTrue(allEntries[2].Equals("0000001"));
        }
コード例 #6
0
        public void BurstTrie_ReconstructBucket()
        {
            BurstTrie trie = new BurstTrie();

            BurstTrie.BurstThreshold = 5;

            string s = "TE";

            for (int i = 0; i < 7; i++)
            {
                trie.Add(s + (char)(65 + i));
            }

            List <string> all = trie.GetAllEntries();

            Assert.IsTrue(all.Contains("TEA"));
            Assert.IsTrue(all.Contains("TEF"));
        }