Skip to content

# Subject

## `` mail_intake.parsers.subject

### Summary

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.

### Functions

#### `` normalize_subject

    1

    normalize_subject(subject: str) -> str

Normalize an email subject for thread-level comparison.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`subject` | `str` | Raw subject line from a message header. | required

Returns:

Name | Type | Description
--- | --- | ---
`str` | `str` | Normalized subject string suitable for thread grouping.

Notes

Responsibilities:

    1
    2
    3
    4

    - Strips common prefixes such as `Re:`, `Fwd:`, and `FW:`.
    - Repeats prefix stripping to handle stacked prefixes.
    - Collapses excessive whitespace.
    - Preserves original casing (no lowercasing).

Guarantees:

    1
    2

    - This function is intentionally conservative and avoids aggressive
      transformations that could alter the semantic meaning of the subject.