private static List <string> GetSynonymsForTagWords(TagProcessResult tag) { var returnList = new List <string>(); tag.WordProcessResultList.ForEach(w => returnList.AddRange(Synonyms(w.Word))); return(returnList); }
private static void CheckTagSetTest(List <TagProcessResult> tagList, TagProcessResult tagToCheck) { var tagWordSynonyms = GetSynonymsForTagWords(tagToCheck); var result = (from x in tagList where x.TagId != tagToCheck.TagId where !x.DuplicateTagId.HasValue where !x.RelatedTagId.HasValue let foundDuplicateTagId = !tagToCheck.IsDuplicateReference && x.TagValue.ToLower() == tagToCheck.TagValue.ToLower() ? x.TagId : (int?)null let foundPartialDuplicateTagId = !tagToCheck.IsRelatedReference && x.WordProcessResultList.Any(a => tagToCheck.WordProcessResultList.Select(wpr => wpr.Word.ToLower()).Contains(a.Word.ToLower())) ? x.TagId : (int?)null let foundSynonymTagId = !tagToCheck.IsRelatedReference && x.WordProcessResultList.Any(w => tagWordSynonyms.Contains(w.Word.ToLower())) ? x.TagId : (int?)null select new { DuplicateTagId = foundDuplicateTagId, RelatedTagId = foundPartialDuplicateTagId ?? foundSynonymTagId }).FirstOrDefault(); if (result != null) { if (result.DuplicateTagId.HasValue) { tagToCheck.DuplicateTagId = result.DuplicateTagId; tagList.Find(t => t.TagId == result.DuplicateTagId).IsDuplicateReference = true; } if (result.RelatedTagId.HasValue) { tagToCheck.RelatedTagId = result.RelatedTagId; tagList.Find(t => t.TagId == result.RelatedTagId).IsRelatedReference = true; } } }
private static void CheckTagSetForDuplicates(List<TagProcessResult> tagList, TagProcessResult tpr) { var duplicateTagId = tagList.Where(t => t.TagId != tpr.TagId) .Where(t => !t.DuplicateTagId.HasValue) .Where(t => t.TagValue.ToLower() == tpr.TagValue.ToLower()) .Select(t => t.TagId).FirstOrDefault(); if (duplicateTagId != default(int)) { tpr.DuplicateTagId = duplicateTagId; } }
private static void CheckRepositoryForDuplicates(TagProcessResult tpr) { using (var context = new TagGardeningContext()) { var repoMediaTagId = context.MediaTags.Where(mt => mt.MediaTagValue.ToLower() == tpr.TagValue.ToLower()) .Select(mt => mt.MediaTagId) .SingleOrDefault(); if (repoMediaTagId != default(int)) { tpr.MediaTagId = repoMediaTagId; } } }
private static void CheckTagSetForSynonyms(List <TagProcessResult> tagList, TagProcessResult tpr) { var synonymTagId = 0; foreach (var wpr in tpr.WordProcessResultList) { var wordSynonyms = Synonyms(wpr.Word); if (wordSynonyms.Any()) { synonymTagId = tagList.Where(t => t.TagId != tpr.TagId) .Where(t => !t.SynonymTagId.HasValue) .Where(t => t.WordProcessResultList.Any(x => wordSynonyms.Contains(x.Word))) .Select(x => x.TagId) .FirstOrDefault(); } } if (synonymTagId != default(int)) { tpr.SynonymTagId = synonymTagId; } }
private static void CheckTagSetForDuplicates(List <TagProcessResult> tagList, TagProcessResult tpr) { var duplicateTagId = tagList.Where(t => t.TagId != tpr.TagId) .Where(t => !t.DuplicateTagId.HasValue) .Where(t => t.TagValue.ToLower() == tpr.TagValue.ToLower()) .Select(t => t.TagId).FirstOrDefault(); if (duplicateTagId != default(int)) { tpr.DuplicateTagId = duplicateTagId; } }
private static void CheckTagSetForSynonyms(List<TagProcessResult> tagList, TagProcessResult tpr) { var synonymTagId = 0; foreach (var wpr in tpr.WordProcessResultList) { var wordSynonyms = Synonyms(wpr.Word); if (wordSynonyms.Any()) { synonymTagId = tagList.Where(t => t.TagId != tpr.TagId) .Where(t => !t.SynonymTagId.HasValue) .Where(t => t.WordProcessResultList.Any(x => wordSynonyms.Contains(x.Word))) .Select(x => x.TagId) .FirstOrDefault(); } } if (synonymTagId != default(int)) { tpr.SynonymTagId = synonymTagId; } }
private static List<string> GetSynonymsForTagWords(TagProcessResult tag) { var returnList = new List<string>(); tag.WordProcessResultList.ForEach(w => returnList.AddRange(Synonyms(w.Word))); return returnList; }
private static void CheckTagSetTest(List<TagProcessResult> tagList, TagProcessResult tagToCheck) { var tagWordSynonyms = GetSynonymsForTagWords(tagToCheck); var result = (from x in tagList where x.TagId != tagToCheck.TagId where !x.DuplicateTagId.HasValue where !x.RelatedTagId.HasValue let foundDuplicateTagId = !tagToCheck.IsDuplicateReference && x.TagValue.ToLower() == tagToCheck.TagValue.ToLower() ? x.TagId : (int?)null let foundPartialDuplicateTagId = !tagToCheck.IsRelatedReference && x.WordProcessResultList.Any(a => tagToCheck.WordProcessResultList.Select(wpr => wpr.Word.ToLower()).Contains(a.Word.ToLower())) ? x.TagId : (int?)null let foundSynonymTagId = !tagToCheck.IsRelatedReference && x.WordProcessResultList.Any(w => tagWordSynonyms.Contains(w.Word.ToLower())) ? x.TagId : (int?)null select new { DuplicateTagId = foundDuplicateTagId, RelatedTagId = foundPartialDuplicateTagId ?? foundSynonymTagId }).FirstOrDefault(); if (result != null) { if (result.DuplicateTagId.HasValue) { tagToCheck.DuplicateTagId = result.DuplicateTagId; tagList.Find(t => t.TagId == result.DuplicateTagId).IsDuplicateReference = true; } if (result.RelatedTagId.HasValue) { tagToCheck.RelatedTagId = result.RelatedTagId; tagList.Find(t => t.TagId == result.RelatedTagId).IsRelatedReference = true; } } }