Subject
mail_intake.parsers.subject
Subject line normalization utilities for Mail Intake.
This module provides helper functions for normalizing email subject lines to enable reliable thread-level comparison and grouping.
Normalization is intentionally conservative to avoid altering semantic meaning while removing common reply and forward prefixes.
normalize_subject
normalize_subject(subject: str) -> str
Normalize an email subject for thread-level comparison.
Operations:
- Strips common prefixes such as Re:, Fwd:, and FW:
- Repeats prefix stripping to handle stacked prefixes
- Collapses excessive whitespace
- Preserves original casing (no lowercasing)
This function is intentionally conservative and avoids aggressive transformations that could alter the semantic meaning of the subject.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject |
str
|
Raw subject line from a message header. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Normalized subject string suitable for thread grouping. |