human handoffs
This commit is contained in:
parent
79188e0f59
commit
36a55930f9
35 changed files with 4039 additions and 139 deletions
16
backend/app/services/subject_normalize.py
Normal file
16
backend/app/services/subject_normalize.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import re
|
||||
|
||||
_PREFIX_PATTERN = re.compile(
|
||||
r"^(?:(?:re|fw|fwd)\s*(?:\[\d+\])?\s*:\s*)+",
|
||||
flags=re.IGNORECASE,
|
||||
)
|
||||
|
||||
|
||||
def normalize_subject(subject: str | None) -> str:
|
||||
value = (subject or "").strip()
|
||||
while True:
|
||||
next_value = _PREFIX_PATTERN.sub("", value, count=1).strip()
|
||||
if next_value == value:
|
||||
break
|
||||
value = next_value
|
||||
return re.sub(r"\s+", " ", value).strip().lower()
|
||||
Loading…
Add table
Add a link
Reference in a new issue