Reduce program plugin results (#5743)

* Added minimum score threshold

* nit fix for program plugin
This commit is contained in:
Divyansh Srivastava 2020-08-10 16:25:34 -07:00 committed by GitHub
parent dc35fc450b
commit d21201e996
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -86,8 +86,11 @@ namespace Microsoft.Plugin.Program
.Where(p => p.Enabled)
.Select(p => p.Result(query.Search, _context.API));
var result = results1.Concat(results2).Where(r => r != null && r.Score > 0).ToList();
return result;
var result = results1.Concat(results2).Where(r => r != null && r.Score > 0);
var maxScore = result.Max(x => x.Score);
result = result.Where(x => x.Score > _settings.MinScoreThreshold * maxScore);
return result.ToList();
}
public void Init(PluginInitContext context)

View File

@ -19,6 +19,8 @@ namespace Microsoft.Plugin.Program
public bool EnablePathEnvironmentVariableSource { get; set; } = true;
public double MinScoreThreshold { get; set; } = 0.75;
internal const char SuffixSeparator = ';';
/// <summary>