Spaces:
Sleeping
Sleeping
Nikhil Singh
commited on
Commit
·
01fa41d
1
Parent(s):
2e363f7
email cleaned body
Browse files
app.py
CHANGED
|
@@ -15,6 +15,7 @@ def clean_email(email):
|
|
| 15 |
|
| 16 |
def present(email_content):
|
| 17 |
email = accept_mail(email_content)
|
|
|
|
| 18 |
email_info = {
|
| 19 |
"Subject": email.subject,
|
| 20 |
"From": email.from_,
|
|
@@ -24,29 +25,42 @@ def present(email_content):
|
|
| 24 |
"Headers": email.headers,
|
| 25 |
"Attachments": email.attachments
|
| 26 |
}
|
|
|
|
| 27 |
return [
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
| 35 |
]
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
demo = gr.Interface(
|
| 38 |
fn=present,
|
| 39 |
inputs="text",
|
| 40 |
-
outputs=
|
| 41 |
-
gr.components.Textbox(label="Subject"),
|
| 42 |
-
gr.components.Textbox(label="From"),
|
| 43 |
-
gr.components.Textbox(label="To"),
|
| 44 |
-
gr.components.Textbox(label="Date"),
|
| 45 |
-
gr.components.Textbox(label="Message ID"),
|
| 46 |
-
gr.components.Textbox(label="Headers"),
|
| 47 |
-
gr.components.Textbox(label="Attachments")
|
| 48 |
-
],
|
| 49 |
title="Email Info",
|
| 50 |
-
description="Enter the email content below to view its details."
|
|
|
|
| 51 |
)
|
| 52 |
demo.launch()
|
|
|
|
| 15 |
|
| 16 |
def present(email_content):
|
| 17 |
email = accept_mail(email_content)
|
| 18 |
+
cleaned_text = clean_email(email) # Call clean_email to get cleaned text
|
| 19 |
email_info = {
|
| 20 |
"Subject": email.subject,
|
| 21 |
"From": email.from_,
|
|
|
|
| 25 |
"Headers": email.headers,
|
| 26 |
"Attachments": email.attachments
|
| 27 |
}
|
| 28 |
+
# Outputs are now organized as a list to match the structure for grouped outputs
|
| 29 |
return [
|
| 30 |
+
[
|
| 31 |
+
email_info["Subject"],
|
| 32 |
+
str(email_info["From"]), # Convert list to string for display
|
| 33 |
+
str(email_info["To"]), # Convert list to string for display
|
| 34 |
+
email_info["Date"],
|
| 35 |
+
email_info["Message ID"],
|
| 36 |
+
str(email_info["Headers"]), # Convert dictionary to string for display
|
| 37 |
+
str(email_info["Attachments"]) # Convert list to string for display
|
| 38 |
+
],
|
| 39 |
+
cleaned_text # Cleaned text is the second major block
|
| 40 |
]
|
| 41 |
|
| 42 |
+
outputs = [
|
| 43 |
+
gr.components.Group(
|
| 44 |
+
components=[
|
| 45 |
+
gr.components.Textbox(label="Subject"),
|
| 46 |
+
gr.components.Textbox(label="From"),
|
| 47 |
+
gr.components.Textbox(label="To"),
|
| 48 |
+
gr.components.Textbox(label="Date"),
|
| 49 |
+
gr.components.Textbox(label="Message ID"),
|
| 50 |
+
gr.components.Textbox(label="Headers"),
|
| 51 |
+
gr.components.Textbox(label="Attachments")
|
| 52 |
+
],
|
| 53 |
+
label="Email Details"
|
| 54 |
+
),
|
| 55 |
+
gr.components.Textbox(label="Cleaned Text")
|
| 56 |
+
]
|
| 57 |
+
|
| 58 |
demo = gr.Interface(
|
| 59 |
fn=present,
|
| 60 |
inputs="text",
|
| 61 |
+
outputs=outputs,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
title="Email Info",
|
| 63 |
+
description="Enter the email content below to view its details.",
|
| 64 |
+
layout="horizontal" # Arrange the major output groups horizontally
|
| 65 |
)
|
| 66 |
demo.launch()
|