From 7fe01f07646ddbdfec34d19f1c94527bc73e17bd Mon Sep 17 00:00:00 2001 From: jhdxr Date: Wed, 19 Dec 2018 11:41:41 +0800 Subject: [PATCH] skip calculation of pinyin score if source string is too long (#1683) --- Wox.Infrastructure/StringMatcher.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Wox.Infrastructure/StringMatcher.cs b/Wox.Infrastructure/StringMatcher.cs index 9c793cb622..0ef4f14265 100644 --- a/Wox.Infrastructure/StringMatcher.cs +++ b/Wox.Infrastructure/StringMatcher.cs @@ -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();