private static void SearchInTrie(Stopwatch sw, TrieNode start, MatchCollection words, string searchedWord)
        {
            int wordCount = 0;
            sw.Restart();
            wordCount = start.CountWords(start, searchedWord);
            sw.Stop();

            Console.WriteLine("Times word found: {0}", wordCount);
            Console.WriteLine("Time in searching trie: {0}", sw.Elapsed);
        }
Esempio n. 2
0
        private static void SearchInTrie(Stopwatch sw, TrieNode start, MatchCollection words, string searchedWord)
        {
            int wordCount = 0;

            sw.Restart();
            wordCount = start.CountWords(start, searchedWord);
            sw.Stop();

            Console.WriteLine("Times word found: {0}", wordCount);
            Console.WriteLine("Time in searching trie: {0}", sw.Elapsed);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            ///===========================================
            ///Unzip the archive in the project directory
            ///===========================================

            Stopwatch sw    = new Stopwatch();
            TrieNode  start = new TrieNode();
            Dictionary <string, int> wordsInDictionary = new Dictionary <string, int>();
            var allWords = SetInputText();

            List <string> wordsToSearch = new List <string>();

            // change number to increase searched words count
            for (int i = 0; i < 50; i++)
            {
                wordsToSearch.Add(allWords[i].ToString());
            }

            AddWordsForSearchInDictionary(sw, wordsToSearch, wordsInDictionary);
            AddWordsForSearchInTrie(sw, start, wordsToSearch);

            IncrementOccuranceCountTrie(sw, start, allWords);
            IncrementOccuranceCountDictionary(sw, wordsInDictionary, allWords);


            Console.WriteLine("Searched words count trie: ");
            foreach (var word in wordsToSearch)
            {
                Console.WriteLine("{0}: {1}", word, start.CountWords(start, word));
            }


            Console.WriteLine("\nSearched words count dictionary: ");
            foreach (var item in wordsInDictionary)
            {
                Console.WriteLine("{0}: {1}", item.Key, item.Value);
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            ///===========================================
            ///Unzip the archive in the project directory
            ///===========================================
            
            Stopwatch sw = new Stopwatch();
            TrieNode start = new TrieNode();
            Dictionary<string, int> wordsInDictionary = new Dictionary<string, int>();
            var allWords = SetInputText();

            List<string> wordsToSearch = new List<string>();
            // change number to increase searched words count
            for (int i = 0; i < 50; i++)
            {
                wordsToSearch.Add(allWords[i].ToString());
            }

            AddWordsForSearchInDictionary(sw, wordsToSearch, wordsInDictionary);
            AddWordsForSearchInTrie(sw, start, wordsToSearch);

            IncrementOccuranceCountTrie(sw, start, allWords);
            IncrementOccuranceCountDictionary(sw, wordsInDictionary, allWords);
            

            Console.WriteLine("Searched words count trie: ");
            foreach (var word in wordsToSearch)
            {
                Console.WriteLine("{0}: {1}", word, start.CountWords(start, word));
            }


            Console.WriteLine("\nSearched words count dictionary: ");
            foreach (var item in wordsInDictionary)
            {
                Console.WriteLine("{0}: {1}", item.Key, item.Value);
            }
        }