Skip to content

Commit 68811fa

Browse files
committed
Add demo for FuzzySharp (Levenshtein)
1 parent 309ee29 commit 68811fa

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

Flow.Launcher.Plugin/SharedModels/MatchResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ private int ScoreAfterSearchPrecisionFilter(int rawScore)
6565

6666
public enum SearchPrecisionScore
6767
{
68-
Regular = 50,
69-
Low = 20,
68+
Regular = 0,
69+
Low = 0,
7070
None = 0
7171
}
7272
}

Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
</ItemGroup>
5959

6060
<ItemGroup>
61+
<PackageReference Include="FuzzySharp" Version="2.0.2" />
6162
<PackageReference Include="System.Runtime" Version="4.3.1" />
6263
</ItemGroup>
6364

Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,26 @@ public Result Result(string query, IPublicAPI api)
9393

9494
matchResult.MatchData = new List<int>();
9595
}
96+
97+
98+
99+
96100

101+
var newScore = FuzzySharp.Fuzz.PartialTokenSetRatio(query.ToLower(), Name.ToLower());
102+
if (Name.Length < query.Length)
103+
newScore = 0;
104+
105+
var oldScore = matchResult.RawScore;
106+
matchResult.RawScore = Math.Max(newScore, oldScore);
107+
matchResult.MatchData = new List<int>();
108+
109+
110+
111+
112+
97113
var result = new Result
98114
{
99-
Title = title,
115+
Title = title + $"<{matchResult.Score}> <{newScore}> <{oldScore}>",
100116
SubTitle = LnkResolvedPath ?? FullPath,
101117
IcoPath = IcoPath,
102118
Score = matchResult.Score,

0 commit comments

Comments
 (0)