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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user