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); } }
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); } }
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); } }
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); } }
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); }
public static string getPinyinString(string source) { if (Alphabet.ContainsChinese(source)) { return(Alphabet.PinyinComination(source)); } return(source); }
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); }