Ejemplo n.º 1
0
 public WordTrieNode(WordNodeConfig config, WordTrieNode parent, Word wordToAdd, bool isNodeValue)
     : this(config)
 {
     _parent = parent;
       _word = isNodeValue ? wordToAdd : null;
       _mostPopularWords.Add(wordToAdd);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Create an instance of <see cref="IWordCollection"/> object.
 /// </summary>
 /// <param name="matchByTrie">Defines a type of <see cref="IWordCollection"/> object that will used for words processing.</param>
 /// <param name="config"><see cref="WordNodeConfig"/></param>
 public static IWordCollection CreateWordsCollection(StandaloneMode mode, WordNodeConfig config)
 {
     switch(mode)
       {
     case StandaloneMode.Dictionary:
       return new WordDictionaryCollection(config.MostPopularWordsLimit);
     case StandaloneMode.HashSet:
       return new WordHashSetCollection(config.MostPopularWordsLimit);
     default:
       return new WordTrieCollection(config);
       }
 }
 public WordTrieCollection(WordNodeConfig config)
     : base(config)
 {
 }
Ejemplo n.º 4
0
 private static void InitializeWordsCollection(string[] args)
 {
     StandaloneMode mode = StandaloneMode.Trie;
       if (args.Length == 1)
     Enum.TryParse<StandaloneMode>(args[0].Substring(1), true, out mode);
       int mostPopularWordsLimit = Convert.ToInt32(ConfigurationManager.AppSettings["MostPopularWordsLimit"]);
       var config = new WordNodeConfig { MostPopularWordsLimit = mostPopularWordsLimit };
       _wordCollection = CommonHelper.CreateWordsCollection(mode, config);
       Console.WriteLine("Standalone mode: {0}", mode.ToString());
 }
Ejemplo n.º 5
0
 public WordTrieNode(WordNodeConfig config)
 {
     _config = config;
       _mostPopularWords = new MostPopularWords(config.MostPopularWordsLimit);
       _childNodes = new Dictionary<char, WordTrieNode>();
 }