Update app.py
Browse files
app.py
CHANGED
|
@@ -38,9 +38,9 @@ classifier = EmailClassifier(model_path=model_path)
|
|
| 38 |
def process_email(email_body):
|
| 39 |
"""
|
| 40 |
Process email by masking PII and classifying it.
|
| 41 |
-
|
| 42 |
email_body: Raw email text
|
| 43 |
-
|
| 44 |
tuple: (masked_email, entities_text, category)
|
| 45 |
"""
|
| 46 |
# Mask PII
|
|
@@ -52,11 +52,10 @@ def process_email(email_body):
|
|
| 52 |
# Classify email
|
| 53 |
category = classifier.classify(processed_email)
|
| 54 |
|
| 55 |
-
# Format entities for display
|
| 56 |
-
entities_text = "
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
])
|
| 60 |
|
| 61 |
return masked_email, entities_text, category
|
| 62 |
|
|
@@ -98,7 +97,7 @@ demo = gr.Interface(
|
|
| 98 |
],
|
| 99 |
article="""
|
| 100 |
## How It Works
|
| 101 |
-
|
| 102 |
2. **Email Classification**: The masked email is classified into categories
|
| 103 |
3. **Results**: View the masked version, detected PII, and email category
|
| 104 |
"""
|
|
|
|
| 38 |
def process_email(email_body):
|
| 39 |
"""
|
| 40 |
Process email by masking PII and classifying it.
|
| 41 |
+
Args:
|
| 42 |
email_body: Raw email text
|
| 43 |
+
Returns:
|
| 44 |
tuple: (masked_email, entities_text, category)
|
| 45 |
"""
|
| 46 |
# Mask PII
|
|
|
|
| 52 |
# Classify email
|
| 53 |
category = classifier.classify(processed_email)
|
| 54 |
|
| 55 |
+
# Format entities for display - fixed formatting
|
| 56 |
+
entities_text = ""
|
| 57 |
+
for entity in entities:
|
| 58 |
+
entities_text += f"- {entity['classification']}: {entity['entity']}\n"
|
|
|
|
| 59 |
|
| 60 |
return masked_email, entities_text, category
|
| 61 |
|
|
|
|
| 97 |
],
|
| 98 |
article="""
|
| 99 |
## How It Works
|
| 100 |
+
1. **PII Masking**: The system identifies and masks personal information
|
| 101 |
2. **Email Classification**: The masked email is classified into categories
|
| 102 |
3. **Results**: View the masked version, detected PII, and email category
|
| 103 |
"""
|