(text: str, phrases: Sequence[str])
| 326 | |
| 327 | |
| 328 | def phrase_alignment_score(text: str, phrases: Sequence[str]) -> float: |
| 329 | normalized_text = normalize_phrase_text(text) |
| 330 | if not normalized_text or not phrases: |
| 331 | return 0.0 |
| 332 | weighted_hits = 0.0 |
| 333 | total_weight = 0.0 |
| 334 | for phrase in phrases: |
| 335 | normalized_phrase = normalize_phrase_text(phrase) |
| 336 | if not normalized_phrase: |
| 337 | continue |
| 338 | weight = 1.0 + min(2.0, max(0, len(normalized_phrase.split()) - 1) * 0.35) |
| 339 | total_weight += weight |
| 340 | if contains_phrase(normalized_text, normalized_phrase): |
| 341 | weighted_hits += weight |
| 342 | if total_weight <= 0: |
| 343 | return 0.0 |
| 344 | return clamp(weighted_hits / min(total_weight, 8.0)) |
| 345 | |
| 346 | |
| 347 | def aspect_coverage_score(text: str, directions: Sequence[str]) -> float: |
no test coverage detected