skip calculation of pinyin score if source string is too long (#1683)

This commit is contained in:
jhdxr 2018-12-19 11:41:41 +08:00
parent d7da96b387
commit 7fe01f0764

View File

@ -26,9 +26,15 @@ namespace Wox.Infrastructure
{
if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
{
FuzzyMatcher matcher = FuzzyMatcher.Create(target);
if(source.Length > 40)
{
Log.Debug($"|Wox.Infrastructure.StringMatcher.ScoreForPinyin|skip too long string: {source}");
return 0;
}
if (Alphabet.ContainsChinese(source))
{
FuzzyMatcher matcher = FuzzyMatcher.Create(target);
var combination = Alphabet.PinyinComination(source);
var pinyinScore = combination.Select(pinyin => matcher.Evaluate(string.Join("", pinyin)).Score)
.Max();