Beispiel #1
0
        private static IEnumerable <JaVi> SearchHanViet(SearchArgs searchArgs)
        {
            var key         = searchArgs.SearchKey;
            var arr         = key.Split(' ');
            var kanjiOfWord = arr.Length;
            var result      = new List <JaVi>();
            var context     = JazeDatabaseContext.Context;

            foreach (var simpleJavi in _javiHanVietCaches)
            {
                if (simpleJavi.HanViet.Count == kanjiOfWord)
                {
                    bool flag = true;
                    for (int i = 0; i < kanjiOfWord; i++)
                    {
                        if (simpleJavi.HanViet2[i].All(hv => hv != arr[i]))
                        {
                            flag = false;
                            break;
                        }
                    }
                    if (flag)
                    {
                        var javi = context.JaVis.Find(simpleJavi.DbId);
                        if (javi != null)
                        {
                            result.Add(javi);
                        }
                    }
                }
            }
            return(result);
            //switch (searchArgs.Option)
            //{
            //    case SearchOption.Exact:
            //        return SearchExact(key);
            //    case SearchOption.StartWith:
            //        return SearchStartWith(key);
            //    case SearchOption.EndWith:
            //        return SearchEndWith(key);
            //    case SearchOption.Contain:
            //        return SearchContain(key);
            //    default:
            //        throw new ArgumentOutOfRangeException();
            //}
        }
Beispiel #2
0
        public static IEnumerable <Kanji> Search(SearchArgs searchArgs)
        {
            var key = searchArgs.SearchKey;

            //
            if (string.IsNullOrWhiteSpace(key))
            {
                return(GetAll());
            }
            //if search key contain multi kanji
            var arr = StringUtil.FilterCharsInString(key, CharSet.Kanji);

            if (arr.Count > 0)
            {
                return(LoadKanji(arr));
            }
            //if search key is vietnamese sentence
            if (key.Contains(" "))
            {
                return(SearchVietNameseSentence(key));
            }
            //other case
            switch (searchArgs.Option)
            {
            case SearchOption.Exact:
                return(SearchExact(key));

            case SearchOption.StartWith:
                return(SearchStartWith(key));

            case SearchOption.EndWith:
                return(SearchEndWith(key));

            case SearchOption.Contain:
                return(SearchContain(key));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #3
0
        private static IEnumerable <JaVi> SearchJapanese(SearchArgs searchArgs)
        {
            var key = searchArgs.SearchKey;

            switch (searchArgs.Option)
            {
            case SearchOption.Exact:
                return(SearchExact(key));

            case SearchOption.StartWith:
                return(SearchStartWith(key));

            case SearchOption.EndWith:
                return(SearchEndWith(key));

            case SearchOption.Contain:
                return(SearchContain(key));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #4
0
        public static IEnumerable <Grammar> Search(SearchArgs searchArgs)
        {
            var key = searchArgs.SearchKey;

            if (string.IsNullOrWhiteSpace(key))
            {
                return(GetAll());
            }

            //switch (searchArgs.Option)
            //{
            //    case SearchOption.Exact:
            //        return SearchExact(key);
            //    case SearchOption.StartWith:
            //        return SearchStartWith(key);
            //    case SearchOption.EndWith:
            //        return SearchEndWith(key);
            //    case SearchOption.Contain:
            //        return SearchContain(key);
            //    default:
            //        throw new ArgumentOutOfRangeException();
            //}
            return(SearchContain(key));
        }
Beispiel #5
0
        public static IEnumerable <JaVi> Search(SearchArgs searchArgs)
        {
            var rawKey = searchArgs.SearchKey;

            if (string.IsNullOrWhiteSpace(rawKey))
            {
                //return GetAll();
                return(null);
            }
            var key = rawKey.Contains("-") ? StringUtil.ConvertRomaji2Katakana(rawKey) : StringUtil.ConvertRomaji2Hiragana(rawKey);
            IEnumerable <JaVi> resultJv = new JaVi[] {};
            IEnumerable <JaVi> resultHv = new JaVi[] { };

            if (StringUtil.IsJapanese(key))
            {
                resultJv = SearchJapanese(new SearchArgs(key, searchArgs.Option));
            }

            if (rawKey.Split(' ').All(StringUtil.IsVietnamese))
            {
                resultHv = SearchHanViet(searchArgs);
            }
            return(resultJv.Union(resultHv));
        }
Beispiel #6
0
 public static IEnumerable <JaVi> SearchJaVi(SearchArgs args)
 {
     return(JaviSearcher.Search(args));
 }
Beispiel #7
0
 public static IEnumerable <JaEn> SearchJaEn(SearchArgs searchArgs)
 {
     return(JaenSearcher.Search(searchArgs));
 }
Beispiel #8
0
 public static IEnumerable <Grammar> SearchGrammar(SearchArgs searchArgs)
 {
     return(GrammarSearcher.Search(searchArgs));
 }
Beispiel #9
0
 public static IEnumerable <ViJa> SearchViJa(SearchArgs searchArgs)
 {
     return(VijaSearcher.Search(searchArgs));
 }
Beispiel #10
0
 public static IEnumerable <Kanji> SearchKanji(SearchArgs searchArgs)
 {
     return(KanjiSearcher.Search(searchArgs));
 }
Beispiel #11
0
 public static IEnumerable <HanViet> SearchHanViet(SearchArgs searchArgs)
 {
     return(HanVietSearcher.Search(searchArgs));
 }