/// <summary>
        /// Adds synonyms to the thesaurus
        /// </summary>
        /// <param name="synonyms">The synonyms</param>
        public void AddSynonyms(IEnumerable <string> synonyms)
        {
            var synonymsList = synonyms?.Where(x => !string.IsNullOrEmpty(x)).ToList() ?? new List <string>();

            foreach (string synonym in synonymsList)
            {
                var thesaurusWord = _thesaurusWordCache.GetByWord(synonym) ?? new ThesaurusWord(synonym);
                thesaurusWord.AddSynonyms(synonymsList);

                _thesaurusWordCache.Insert(thesaurusWord);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the stored thesaurusWord objects from data store matched by word
        /// </summary>
        /// <param name="targetWord">The target word</param>
        /// <returns>thesaurusWord object</returns>
        public ThesaurusWord GetByWord(string targetWord)
        {
            if (targetWord == null)
            {
                return(null);
            }

            ThesaurusWord cachedThesaurusWord;

            _wordCache.TryGetValue(targetWord, out cachedThesaurusWord);

            return(cachedThesaurusWord ?? _wordStore.GetByWord(targetWord));
        }