const GENERIC_PREFIX_BLOCKLIST: &[&str] = &[
"from",
"into",
"with",
"make",
"create",
"build",
"parse",
"check",
"test",
"init",
"load",
"save",
"read",
"write",
"send",
"recv",
"handle",
"process",
"convert",
"transform",
"validate",
"exec",
"run",
"call",
"apply",
"update",
"delete",
"remove",
"find",
"get",
"set",
"new",
"try",
"is",
"has",
"can",
"should",
];
fn name_cluster(entries: &[&FunctionEntry], file_path: &str) -> (String, String, f32) {
if let Some((name, confidence, _reason)) = try_dominant_type(entries) {
return (name, "DominantType".to_string(), confidence);
}
if let Some((name, confidence, _reason)) = try_function_theme(entries) {
return (name, "FunctionTheme".to_string(), confidence);
}
if let Some((name, confidence, _reason)) = try_common_prefix(entries) {
if !GENERIC_PREFIX_BLOCKLIST.contains(&name.as_str()) {
return (name, "CommonPrefix".to_string(), confidence);
}
}
if let Some((name, confidence, _reason)) = try_doc_comment_consensus(entries) {
return (name, "DocCommentConsensus".to_string(), confidence);
}
if let Some(word) = find_context_word(entries) {
return (word, "ContextWord".to_string(), 0.5);
}
let stem = Path::new(file_path)
.file_stem()
.and_then(|s| s.to_str())
.unwrap_or("module");
(format!("{}_cluster", stem), "Fallback".to_string(), 0.2)
}