ContainsChinese() public static method

public static ContainsChinese ( string word ) : bool
word string
return bool
示例#1
0
        public static int ScoreForPinyin(string source, string target)
        {
            if (!ShouldUsePinyin)
            {
                return(0);
            }

            if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
            {
                if (Alphabet.ContainsChinese(source))
                {
                    var combination = Alphabet.PinyinComination(source);
                    var pinyinScore = combination
                                      .Select(pinyin => FuzzySearch(target, string.Join("", pinyin)).Score)
                                      .Max();
                    var acronymScore = combination.Select(Alphabet.Acronym)
                                       .Select(pinyin => FuzzySearch(target, pinyin).Score)
                                       .Max();
                    var score = Math.Max(pinyinScore, acronymScore);
                    return(score);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
示例#2
0
 public static int ScoreForPinyin(string source, string target)
 {
     if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
     {
         FuzzyMatcher matcher = FuzzyMatcher.Create(target);
         //todo happlebao currently generate pinyin on every query, should be generate on startup/index
         if (Alphabet.ContainsChinese(source))
         {
             var combination = Alphabet.PinyinComination(source);
             var pinyinScore = combination.Select(pinyin => matcher.Evaluate(string.Join("", pinyin)).Score)
                               .Max();
             var acronymScore = combination.Select(Alphabet.Acronym)
                                .Select(pinyin => matcher.Evaluate(pinyin).Score)
                                .Max();
             var score = Math.Max(pinyinScore, acronymScore);
             return(score);
         }
         else
         {
             return(0);
         }
     }
     else
     {
         return(0);
     }
 }
示例#3
0
 public static int ScoreForPinyin(string source, string target)
 {
     if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
     {
         FuzzyMatcher matcher = FuzzyMatcher.Create(target);
         if (Alphabet.ContainsChinese(source))
         {
             var combination = Alphabet.PinyinComination(source);
             var pinyinScore = combination.Select(pinyin => matcher.Evaluate(string.Join("", pinyin)).Score)
                               .Max();
             var acronymScore = combination.Select(Alphabet.Acronym)
                                .Select(pinyin => matcher.Evaluate(pinyin).Score)
                                .Max();
             var score = Math.Max(pinyinScore, acronymScore);
             return(score);
         }
         else
         {
             return(0);
         }
     }
     else
     {
         return(0);
     }
 }
示例#4
0
        public static int ScoreForPinyin(string source, string target)
        {
            if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
            {
                if (source.Length > 40)
                {
                    Log.Debug($"|Wox.Infrastructure.StringMatcher.ScoreForPinyin|skip too long string: {source}");
                    return(0);
                }

                if (Alphabet.ContainsChinese(source))
                {
                    var combination = Alphabet.PinyinComination(source);
                    var pinyinScore = combination
                                      .Select(pinyin => FuzzySearch(target, string.Join("", pinyin), new MatchOption()).Score)
                                      .Max();
                    var acronymScore = combination.Select(Alphabet.Acronym)
                                       .Select(pinyin => FuzzySearch(target, pinyin, new MatchOption()).Score)
                                       .Max();
                    var score = Math.Max(pinyinScore, acronymScore);
                    return(score);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
示例#5
0
        public static int ScoreForPinyin(string source, string target)
        {
            if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(target))
            {
                return(0);
            }
            if (source.Length > 40)
            {
                Log.Debug($"|Wox.Infrastructure.StringMatcher.ScoreForPinyin|skip too long string: {source}");
                return(0);
            }

            if (!Alphabet.ContainsChinese(source))
            {
                return(0);
            }
            FuzzyMatcher matcher     = FuzzyMatcher.Create(target);
            var          combination = Alphabet.PinyinComination(source);
            var          pinyinScore = combination.Select(pinyin => matcher.Evaluate(string.Join("", pinyin)).Score)
                                       .Max();
            var acronymScore = combination.Select(Alphabet.Acronym)
                               .Select(pinyin => matcher.Evaluate(pinyin).Score)
                               .Max();
            var score = Math.Max(pinyinScore, acronymScore);

            return(score);
        }
示例#6
0
        public static string getPinyinString(string source)
        {
            if (Alphabet.ContainsChinese(source))
            {
                return(Alphabet.PinyinComination(source));
            }

            return(source);
        }
示例#7
0
        public static int ScoreForPinyinOrEng(string source, string target)
        {
            if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
            {
                if (source.Length > 40)
                {
                    Log.Debug($"|Wox.Infrastructure.StringMatcher.ScoreForPinyin|skip too long string: {source}");
                    return(0);
                }

                if (Alphabet.ContainsChinese(source))
                {
                    var matcher     = FuzzyMatcher.Create(target);
                    var combination = Alphabet.PinyinComination(source);

                    return(matcher.Evaluate(combination).Score);
                }

                return(Score(source, target));
            }

            return(0);
        }