Turn free-form topic text into a stable profile key.
(topic: str)
| 479 | |
| 480 | |
| 481 | def derive_topic_key(topic: str) -> str: |
| 482 | """Turn free-form topic text into a stable profile key.""" |
| 483 | cleaned = re.sub(r"\s+", " ", (topic or "").strip().strip("“”\"'`")) |
| 484 | canonical_key = resolve_canonical_topic_key(cleaned) |
| 485 | if canonical_key: |
| 486 | return canonical_key |
| 487 | normalized = normalize_direction_key(cleaned) |
| 488 | return normalized or cleaned.lower() |
| 489 | |
| 490 | |
| 491 | def clamp_weight(value: float, minimum: float = 0.1, maximum: float = 0.95) -> float: |
nothing calls this directly
no test coverage detected