-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
Using the WeightedRatioScorer for two different strings, one of them gives an unexpected result.
Input
+30.0% Damage to Close Enemies [30.01%+14.3% Damage to Crowd Controlled Enemies [7.5 - 18.0]%
Choices
- "+#% Damage",
- "+#% Damage to Crowd Controlled Enemies",
- "+#% Damage to Close Enemies",
- "+#% Damage to Chilled Enemies",
- "+#% Damage to Poisoned Enemies",
- "#% Block Chance#% Blocked Damage Reduction",
- "#% Damage Reduction from Bleeding Enemies",
- "#% Damage Reduction",
- "+#% Cold Damage"
Results
Scorer: WeightedRatioScorer
Input 1: +30.0% Damage to Close Enemies [30.01%
Main: (string: +#% Damage, score: 90, index: 0)
Main: (string: +#% Damage to Close Enemies, score: 90, index: 2)
Main: (string: +#% Damage to Chilled Enemies, score: 77, index: 3)
Main: (string: +#% Damage to Poisoned Enemies, score: 75, index: 4)
Main: (string: +#% Damage to Crowd Controlled Enemies, score: 67, index: 1)
Main: (string: +#% Cold Damage, score: 61, index: 8)
Main: (string: #% Damage Reduction from Bleeding Enemies, score: 59, index: 6)
Main: (string: #% Damage Reduction, score: 50, index: 7)
Main: (string: #% Block Chance#% Blocked Damage Reduction, score: 48, index: 5)
Elapsed time: 39
---
Scorer: WeightedRatioScorer
Input 2: +14.3% Damage to Crowd Controlled Enemies [7.5 - 18.0]%
Main: (string: +#% Damage to Crowd Controlled Enemies, score: 90, index: 1)
Main: (string: +#% Damage to Close Enemies, score: 73, index: 2)
Main: (string: +#% Damage to Chilled Enemies, score: 69, index: 3)
Main: (string: +#% Damage to Poisoned Enemies, score: 68, index: 4)
Main: (string: +#% Cold Damage, score: 61, index: 8)
Main: (string: +#% Damage, score: 60, index: 0)
Main: (string: #% Damage Reduction from Bleeding Enemies, score: 56, index: 6)
Main: (string: #% Damage Reduction, score: 50, index: 7)
Main: (string: #% Block Chance#% Blocked Damage Reduction, score: 40, index: 5)
Elapsed time: 0
---
For some reason input1 gives +#% Damage a score of 90. While for Input2 it works as expected and +#% Damage gets score of 60.
Source
Here is the source to reproduce the issue.
Click me
using FuzzySharp;
using FuzzySharp.SimilarityRatio;
using FuzzySharp.SimilarityRatio.Scorer.Composite;
using System.Reflection;
namespace FuzzySharpTest
{
internal class Program
{
static void Main(string[] args)
{
string input1 = "+30.0% Damage to Close Enemies [30.01%";
string input2 = "+14.3% Damage to Crowd Controlled Enemies [7.5 - 18.0]%";
List<string> choices = new List<string>()
{
"+#% Damage",
"+#% Damage to Crowd Controlled Enemies",
"+#% Damage to Close Enemies",
"+#% Damage to Chilled Enemies",
"+#% Damage to Poisoned Enemies",
"#% Block Chance#% Blocked Damage Reduction",
"#% Damage Reduction from Bleeding Enemies",
"#% Damage Reduction",
"+#% Cold Damage"
};
// WeightedRatioScorer - input1
var watch = System.Diagnostics.Stopwatch.StartNew();
Console.WriteLine("Scorer: WeightedRatioScorer");
Console.WriteLine($"Input 1: {input1}");
Console.WriteLine(string.Empty);
var results = Process.ExtractTop(input1, choices, scorer: ScorerCache.Get<WeightedRatioScorer>(), limit: 9);
foreach (var r in results)
{
Console.WriteLine($"{MethodBase.GetCurrentMethod()?.Name}: {r}");
}
watch.Stop();
var elapsedMs = watch.ElapsedMilliseconds;
Console.WriteLine($"Elapsed time: {elapsedMs}");
Console.WriteLine("---");
// WeightedRatioScorer - input2
watch = System.Diagnostics.Stopwatch.StartNew();
Console.WriteLine("Scorer: WeightedRatioScorer");
Console.WriteLine($"Input 2: {input2}");
Console.WriteLine(string.Empty);
results = Process.ExtractTop(input2, choices, scorer: ScorerCache.Get<WeightedRatioScorer>(), limit: 9);
foreach (var r in results)
{
Console.WriteLine($"{MethodBase.GetCurrentMethod()?.Name}: {r}");
}
watch.Stop();
elapsedMs = watch.ElapsedMilliseconds;
Console.WriteLine($"Elapsed time: {elapsedMs}");
Console.WriteLine("---");
}
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels