(description: &str, prompt: &str)
| 369 | } |
| 370 | |
| 371 | fn description_confidence(description: &str, prompt: &str) -> f32 { |
| 372 | let shared_terms = significant_terms(description) |
| 373 | .into_iter() |
| 374 | .filter(|term| prompt.contains(term)) |
| 375 | .count(); |
| 376 | let base: f32 = match shared_terms { |
| 377 | 0 => 0.0, |
| 378 | 1 => 0.62, |
| 379 | 2 => 0.74, |
| 380 | _ => 0.80, |
| 381 | }; |
| 382 | |
| 383 | let proactive_match = description.contains("proactive") |
| 384 | && contains_any( |
| 385 | prompt, |
| 386 | &[ |
| 387 | "change", |
| 388 | "changed", |
| 389 | "changes", |
| 390 | "documentation", |
| 391 | "docs", |
| 392 | "fix", |
| 393 | "implement", |
| 394 | "test", |
| 395 | "review", |
| 396 | "verify", |
| 397 | "修改", |
| 398 | "变更", |
| 399 | "修复", |
| 400 | "实现", |
| 401 | "测试", |
| 402 | "审查", |
| 403 | "验证", |
| 404 | ], |
| 405 | ); |
| 406 | |
| 407 | if proactive_match { |
| 408 | (base.max(0.74) + 0.16_f32).min(0.9) |
| 409 | } else if base > 0.0 { |
| 410 | base |
| 411 | } else { |
| 412 | 0.0 |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | fn significant_terms(text: &str) -> Vec<&str> { |
| 417 | text.split(|ch: char| !ch.is_alphanumeric() && ch != '_') |
no test coverage detected