mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Update Program plugin with new code
This commit is contained in:
parent
acd42f9cc6
commit
cc23495591
3 changed files with 21 additions and 10 deletions
|
|
@ -240,9 +240,9 @@ namespace Wox.Plugin.Program.Programs
|
|||
|
||||
private int Score(string query)
|
||||
{
|
||||
var score1 = StringMatcher.Score(DisplayName, query);
|
||||
var score1 = StringMatcher.FuzzySearch(query, DisplayName).ScoreAfterSearchPrecisionFilter();
|
||||
var score2 = StringMatcher.ScoreForPinyin(DisplayName, query);
|
||||
var score3 = StringMatcher.Score(Description, query);
|
||||
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
||||
var score4 = StringMatcher.ScoreForPinyin(Description, query);
|
||||
var score = new[] { score1, score2, score3, score4 }.Max();
|
||||
return score;
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@ namespace Wox.Plugin.Program.Programs
|
|||
|
||||
private int Score(string query)
|
||||
{
|
||||
var score1 = StringMatcher.Score(Name, query);
|
||||
var score1 = StringMatcher.FuzzySearch(query, Name).ScoreAfterSearchPrecisionFilter();
|
||||
var score2 = StringMatcher.ScoreForPinyin(Name, query);
|
||||
var score3 = StringMatcher.Score(Description, query);
|
||||
var score3 = StringMatcher.FuzzySearch(query, Description).ScoreAfterSearchPrecisionFilter();
|
||||
var score4 = StringMatcher.ScoreForPinyin(Description, query);
|
||||
var score5 = StringMatcher.Score(ExecutableName, query);
|
||||
var score5 = StringMatcher.FuzzySearch(query, ExecutableName).ScoreAfterSearchPrecisionFilter();
|
||||
var score = new[] { score1, score2, score3, score4, score5 }.Max();
|
||||
return score;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Wox.Infrastructure.Logger;
|
||||
|
|
@ -29,11 +29,9 @@ namespace Wox.Infrastructure
|
|||
return FuzzySearch(target, source, new MatchOption()).Score > 0;
|
||||
}
|
||||
|
||||
public enum SearchPrecisionScore
|
||||
public static MatchResult FuzzySearch(string query, string stringToCompare)
|
||||
{
|
||||
Regular = 50,
|
||||
Low = 20,
|
||||
None = 0
|
||||
return FuzzySearch(query, stringToCompare, new MatchOption());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -107,6 +105,13 @@ namespace Wox.Infrastructure
|
|||
return score;
|
||||
}
|
||||
|
||||
public enum SearchPrecisionScore
|
||||
{
|
||||
Regular = 50,
|
||||
Low = 20,
|
||||
None = 0
|
||||
}
|
||||
|
||||
public static bool IsSearchPrecisionScoreMet(this MatchResult matchResult)
|
||||
{
|
||||
var precisionScore = (SearchPrecisionScore)Enum.Parse(typeof(SearchPrecisionScore),
|
||||
|
|
@ -114,6 +119,12 @@ namespace Wox.Infrastructure
|
|||
return matchResult.Score >= (int)precisionScore;
|
||||
}
|
||||
|
||||
public static int ScoreAfterSearchPrecisionFilter(this MatchResult matchResult)
|
||||
{
|
||||
return matchResult.IsSearchPrecisionScoreMet() ? matchResult.Score : 0;
|
||||
|
||||
}
|
||||
|
||||
public static int ScoreForPinyin(string source, string target)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(source) && !string.IsNullOrEmpty(target))
|
||||
|
|
|
|||
Loading…
Reference in a new issue