search : recherche fuzzy avec scoring + suggestions vouliez-vous-dire (issue #26) - sous-chaine, subsequence, tolerance de frappe (Levenshtein), tri par pertinence

This commit is contained in:
2026-08-17 08:01:39 -04:00
parent 2eaafe6e2a
commit 4ef89cde72
2 changed files with 169 additions and 25 deletions
+10 -2
View File
@@ -53,8 +53,16 @@ pub fn run(app: &App, keyword: &str, category: Option<&str>) -> Result<i32> {
)
);
if app.catalog.search(keyword, category).is_empty() {
app.log
.info(&format!("no agent matches '{keyword}' (categories: {})", app.catalog.categories().join(", ")));
let suggestions = app.catalog.suggest(keyword);
if suggestions.is_empty() {
app.log
.info(&format!("no agent matches '{keyword}' (categories: {})", app.catalog.categories().join(", ")));
} else {
app.log.info(&format!(
"no agent matches '{keyword}' — vouliez-vous dire : {} ?",
suggestions.join(", ")
));
}
}
Ok(0)
}