public static void Main() { var trie = TrieFactory.GetTrie(); var words = GenerateRandomWords(1000000); var uniqueWords = new HashSet <string>(words); AddWordsToTrie(words, trie); GetCountOfAllUniqueWords(uniqueWords, trie); }
public static void Main(string[] args) { var words = ReadAllWords(); var trie = TrieFactory.GetTrie(); foreach (var word in words) { trie.AddWord(word); } var toSearch = new string[] { "curtain", "you", "well", "lighted" }; foreach (var word in toSearch) { Console.WriteLine("{0} - {1}", word, trie.WordCount(word)); } }
static void Main() { var date = DateTime.Now; var words = GetWords(); Console.WriteLine(DateTime.Now - date); var trie = TrieFactory.GetTrie(); foreach (var word in words) { trie.AddWord(word); } var searched = new[] { "buddhism", "wikipedia", "the", "of", "factors" }; Console.WriteLine(string.Join(" | ", searched.Select(word => string.Format("{0} {1}", word, trie.WordCount(word))))); }
public static ITrie BuildTree() { var wordTrie = TrieFactory.GetTrie(); using (StreamReader textReader = new StreamReader(FileLocation)) { string line = textReader.ReadLine(); while (line != null) { var words = line.Split(Separators, StringSplitOptions.RemoveEmptyEntries); foreach (var word in words) { wordTrie.AddWord(word); } line = textReader.ReadLine(); } } return(wordTrie); }
public static void Main() { System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch(); timer.Start(); var words = GetWords(); timer.Stop(); Console.WriteLine("Adding the words to a collection: {0}", timer.Elapsed); var trie = TrieFactory.GetTrie(); timer.Start(); foreach (var word in words) { trie.AddWord(word); } timer.Stop(); Console.WriteLine("Adding words to the trie: " + timer.Elapsed); timer.Restart(); Console.WriteLine("Number of occurrences of \"the\": {0}", trie.WordCount("the")); Console.WriteLine("Counting the word \"the\": {0}", timer.Elapsed); }