Irannas/Masked_Email_Classification
0
1"""Core logic for email classification and PII masking pipeline."""
2
3from utils import mask_pii
4from models import predict_category
5
6
7def classify_email_pipeline(original_email: str):
8 """Process the input email by masking PII and classifying the email category.
9
10 Args:
11 original_email (str): The raw email text provided by the user.
12
13 Returns:
14 dict: A dictionary containing:
15 - input_email_body (str): The original email content.
16 - list_of_masked_entities (list): List of detected and masked PII entities.
17 - masked_email (str): The email content with PII masked.
18 - category_of_the_email (str): The predicted category of the email.
19 """
20 masked_email, entities = mask_pii(original_email)
21 category = predict_category(masked_email)
22
23 return {
24 "input_email_body": original_email,
25 "list_of_masked_entities": entities,
26 "masked_email": masked_email,
27 "category_of_the_email": category,
28 }
29 