/// <summary> /// Inserts the specified entity. /// </summary> /// <param name="thesaurusWordObject">The thesaurusWord object</param> public void Insert(ThesaurusWord thesaurusWordObject) { if (!_wordCache.ContainsKey(thesaurusWordObject.GetKey())) { _wordCache.Add(thesaurusWordObject.GetKey(), thesaurusWordObject); _wordStore.Insert(thesaurusWordObject); // _wordStore.Save("thesaurus.json"); } }
/// <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); } }