MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / phrase_alignment_score

Function phrase_alignment_score

experiments/baselines/nl_profile/runner.py:328–344  ·  view source on GitHub ↗
(text: str, phrases: Sequence[str])

Source from the content-addressed store, hash-verified

326
327
328def 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
347def aspect_coverage_score(text: str, directions: Sequence[str]) -> float:

Callers 1

score_rowFunction · 0.85

Calls 3

normalize_phrase_textFunction · 0.70
contains_phraseFunction · 0.70
clampFunction · 0.70

Tested by

no test coverage detected