mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
skip calculation of pinyin score if source string is too long (#1683)
This commit is contained in:
parent
d7da96b387
commit
7fe01f0764
1 changed files with 7 additions and 1 deletions
|
|
@ -26,9 +26,15 @@ namespace Wox.Infrastructure
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
|
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))
|
if (Alphabet.ContainsChinese(source))
|
||||||
{
|
{
|
||||||
|
FuzzyMatcher matcher = FuzzyMatcher.Create(target);
|
||||||
var combination = Alphabet.PinyinComination(source);
|
var combination = Alphabet.PinyinComination(source);
|
||||||
var pinyinScore = combination.Select(pinyin => matcher.Evaluate(string.Join("", pinyin)).Score)
|
var pinyinScore = combination.Select(pinyin => matcher.Evaluate(string.Join("", pinyin)).Score)
|
||||||
.Max();
|
.Max();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue