ContainsChinese() public static method

public static ContainsChinese ( string word ) : bool
word string
return bool
コード例 #1
0
ファイル: StringMatcher.cs プロジェクト: jysrfeng/Wox
        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
ファイル: StringMatcher.cs プロジェクト: zgca/CodeHub
 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
ファイル: StringMatcher.cs プロジェクト: zl8989/Wox-launcher
        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);
        }