private Result ConvertMFTSearch(MFTSearchRecord record, string query) { string icoPath = "Images/file.png"; if (record.IsFolder) { icoPath = "Images/folder.png"; } string name = Path.GetFileName(record.FullPath); FuzzyMatcher matcher = FuzzyMatcher.Create(query); return(new Result() { Title = name, Score = matcher.Evaluate(name).Score, SubTitle = record.FullPath, IcoPath = icoPath, Action = _ => { try { Process.Start(record.FullPath); } catch { context.API.ShowMsg("Can't open " + record.FullPath, string.Empty, string.Empty); return false; } return true; }, ContextMenu = GetContextMenu(record) }); }
private bool MatchProgram(Bookmark bookmark, FuzzyMatcher matcher) { if ((bookmark.Score = matcher.Evaluate(bookmark.Name).Score) > 0) { return(true); } if ((bookmark.Score = matcher.Evaluate(bookmark.PinyinName).Score) > 0) { return(true); } if ((bookmark.Score = matcher.Evaluate(bookmark.Url).Score / 10) > 0) { return(true); } return(false); }
private bool MatchProgram(ControlPanelItem item, FuzzyMatcher matcher) { if (item.LocalizedString != null && (item.Score = matcher.Evaluate(item.LocalizedString).Score) > 0) { return(true); } if (item.InfoTip != null && (item.Score = matcher.Evaluate(item.InfoTip).Score) > 0) { return(true); } if (item.LocalizedString != null && (item.Score = matcher.Evaluate(item.LocalizedString.Unidecode()).Score) > 0) { return(true); } return(false); }
private bool MatchProgram(Program program, FuzzyMatcher matcher) { var scores = new List <string> { program.Title, program.PinyinTitle, program.AbbrTitle, program.ExecuteName }; program.Score = scores.Select(s => matcher.Evaluate(s ?? string.Empty).Score).Max(); return(program.Score > 0); }
/// <summary> /// Check if a candidate is match with the source /// </summary> /// <param name="source"></param> /// <param name="candidate"></param> /// <returns>Match score</returns> public static int Match(string source, string candidate) { if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(candidate)) { return(0); } FuzzyMatcher matcher = FuzzyMatcher.Create(candidate); int score = matcher.Evaluate(source).Score; if (score > 0) { return(score); } score = matcher.Evaluate(source.Unidecode()).Score; return(score); }
private bool MatchProgram(Program program, FuzzyMatcher matcher) { if ((program.Score = matcher.Evaluate(program.Title).Score) > 0) { return(true); } if ((program.Score = matcher.Evaluate(program.PinyinTitle).Score) > 0) { return(true); } if (program.AbbrTitle != null && (program.Score = matcher.Evaluate(program.AbbrTitle).Score) > 0) { return(true); } if (program.ExecuteName != null && (program.Score = matcher.Evaluate(program.ExecuteName).Score) > 0) { return(true); } return(false); }