From b45095a350df404350c22b8e5c07e976090f4cb2 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 18 Sep 2018 23:34:45 +0000 Subject: [PATCH] --- server/AyaNova/biz/Search.cs | 71 +++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index 86227dd2..ad4e3fee 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -20,7 +20,7 @@ namespace AyaNova.Biz //WordBreaker - break down into words //ProcessKeywords into database - + #region ProcessKeywords into Database /// /// Process the keywords into the dictionary /// @@ -58,12 +58,29 @@ namespace AyaNova.Biz // ct.SaveChanges(); } + #endregion + + + #region Breaker + + //Class to hold relevant locale data for breaking text + public class LocaleWordBreakingData + { + public bool CJKIndex { get; set; } + public List StopWords { get; set; } + public LocaleWordBreakingData() + { + CJKIndex = false; + StopWords = new List(); + } + } + //Get the current stopwords for the user's locale - private static LocaleSearchData GetLocaleSearchData(long localeId, AyContext ct = null) + private static LocaleWordBreakingData GetLocaleSearchData(long localeId, AyContext ct = null) { - LocaleSearchData LSD = new LocaleSearchData(); + LocaleWordBreakingData LSD = new LocaleWordBreakingData(); if (ct == null) ct = ServiceProviderProvider.DBContext; //Get stopwords @@ -92,11 +109,6 @@ namespace AyaNova.Biz return LSD; } - - - - #region Breaker - public enum TokenTypes { Nothing, Separator, CJK, Latin }; @@ -140,7 +152,7 @@ namespace AyaNova.Biz internal static string BreakCore(long localeId, bool KeepWildCards, params string[] text) { //Get stopwords and CJKIndex flag value - LocaleSearchData LSD = GetLocaleSearchData(localeId); + LocaleWordBreakingData LSD = GetLocaleSearchData(localeId); int MAXWORDLENGTH = 255; StringBuilder sbResults = new StringBuilder(); //List to temporarily hold parsed words @@ -397,38 +409,29 @@ namespace AyaNova.Biz //bail early if there is nothing indexed if (tempParsedWords.Count == 0) return ""; - - //Make a return string array - //from the word list - foreach (string s in tempParsedWords) - { - //Add only non stopwords - if (!StopList.Contains(s)) - { - sbResults.Append(s); - sbResults.Append(","); - } - } - //sometimes all the results are stop words so you end up - //here with nothing in sbResults. - return sbResults.ToString().TrimEnd(','); + //Make a return string array + //from the word list + foreach (string s in tempParsedWords) + { + //Add only non stopwords + if (!StopList.Contains(s)) + { + sbResults.Append(s); + sbResults.Append(","); + } + } + + //sometimes all the results are stop words so you end up + //here with nothing in sbResults. + return sbResults.ToString().TrimEnd(','); } #endregion - public class LocaleSearchData - { - public bool CJKIndex { get; set; } - public List StopWords { get; set; } - public LocaleSearchData() - { - CJKIndex = false; - StopWords = new List(); - } - } + }//eoc