Trim topic text extracted from profile-update messages.
(topic: str, *, strip_domain_suffix: bool = False)
| 1338 | |
| 1339 | |
| 1340 | def clean_profile_topic_text(topic: str, *, strip_domain_suffix: bool = False) -> str: |
| 1341 | """Trim topic text extracted from profile-update messages.""" |
| 1342 | cleaned = re.sub(r"\s+", " ", (topic or "").strip().strip("“”\"'`")) |
| 1343 | cleaned = cleaned.strip(",。!?,.!?;;::()()[]【】") |
| 1344 | if strip_domain_suffix: |
| 1345 | cleaned = re.sub(r"\s*(?:方向|领域|主题)$", "", cleaned, flags=re.IGNORECASE).strip() |
| 1346 | return cleaned |
| 1347 | |
| 1348 | |
| 1349 | def parse_weight_target(value: Any) -> Optional[float]: |
no outgoing calls
no test coverage detected