Find the closest matching string to the target string in the candidates list, using edit distance(case insensitive) Input `candidates` must not be empty otherwise an error is returned.
(candidates: Vec<String>, target: &str)
| 72 | /// Find the closest matching string to the target string in the candidates list, using edit distance(case insensitive) |
| 73 | /// Input `candidates` must not be empty otherwise an error is returned. |
| 74 | fn find_closest_match(candidates: Vec<String>, target: &str) -> Option<String> { |
| 75 | let target = target.to_lowercase(); |
| 76 | candidates.into_iter().min_by_key(|candidate| { |
| 77 | datafusion_common::utils::datafusion_strsim::levenshtein( |
| 78 | &candidate.to_lowercase(), |
| 79 | &target, |
| 80 | ) |
| 81 | }) |
| 82 | } |
| 83 | |
| 84 | /// Arguments for a function call extracted from the SQL AST |
| 85 | #[derive(Debug)] |
no test coverage detected
searching dependent graphs…