Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,11 +29,11 @@ def analyze_email(email_body):
|
|
| 29 |
else:
|
| 30 |
return "negative", (f"This email is not spam (Confidence: {spam_confidence:.2f}).\n"
|
| 31 |
f"Sentiment: {sentiment} (Confidence: {sentiment_confidence:.2f}).\n"
|
| 32 |
-
"**
|
| 33 |
|
| 34 |
def main():
|
| 35 |
-
st.title("
|
| 36 |
-
st.write("
|
| 37 |
|
| 38 |
# Initialize session state
|
| 39 |
if "email_body" not in st.session_state:
|
|
@@ -68,13 +68,13 @@ The Security Team
|
|
| 68 |
spam_snippet = "Subject: Urgent: Verify Your Account Now! Dear Customer, We have detected unusual activity..."
|
| 69 |
|
| 70 |
sample_not_spam_positive = """
|
| 71 |
-
Subject: Great
|
| 72 |
-
|
| 73 |
-
I just
|
| 74 |
-
Best,
|
| 75 |
-
|
| 76 |
"""
|
| 77 |
-
positive_snippet = "Subject: Great
|
| 78 |
|
| 79 |
sample_not_spam_negative = """
|
| 80 |
Subject: Issue with Recent Delivery
|
|
@@ -176,24 +176,4 @@ Sarah
|
|
| 176 |
st.session_state.result_type = result_type
|
| 177 |
else:
|
| 178 |
st.session_state.result = "Please enter an email body or select a sample to analyze."
|
| 179 |
-
st
|
| 180 |
-
with col_clear:
|
| 181 |
-
if st.button("Clear", key="clear"):
|
| 182 |
-
st.session_state.email_body = ""
|
| 183 |
-
st.session_state.result = ""
|
| 184 |
-
st.session_state.result_type = ""
|
| 185 |
-
st.rerun()
|
| 186 |
-
|
| 187 |
-
# Display result with styled box
|
| 188 |
-
if st.session_state.result:
|
| 189 |
-
if st.session_state.result_type == "spam":
|
| 190 |
-
st.markdown(f'<div class="spam-result">{st.session_state.result}</div>', unsafe_allow_html=True)
|
| 191 |
-
elif st.session_state.result_type == "positive":
|
| 192 |
-
st.markdown(f'<div class="positive-result">{st.session_state.result}</div>', unsafe_allow_html=True)
|
| 193 |
-
elif st.session_state.result_type == "negative":
|
| 194 |
-
st.markdown(f'<div class="negative-result">{st.session_state.result}</div>', unsafe_allow_html=True)
|
| 195 |
-
else:
|
| 196 |
-
st.write(st.session_state.result) # For error messages
|
| 197 |
-
|
| 198 |
-
if __name__ == "__main__":
|
| 199 |
-
main()
|
|
|
|
| 29 |
else:
|
| 30 |
return "negative", (f"This email is not spam (Confidence: {spam_confidence:.2f}).\n"
|
| 31 |
f"Sentiment: {sentiment} (Confidence: {sentiment_confidence:.2f}).\n"
|
| 32 |
+
"**Need to Follow-Up**: This email is not spam and has negative sentiment.")
|
| 33 |
|
| 34 |
def main():
|
| 35 |
+
st.title("EmailSentry")
|
| 36 |
+
st.write("Aims to perform analysis on incoming emails and to determine whether there is urgency or higher priority for the company to follow-up.")
|
| 37 |
|
| 38 |
# Initialize session state
|
| 39 |
if "email_body" not in st.session_state:
|
|
|
|
| 68 |
spam_snippet = "Subject: Urgent: Verify Your Account Now! Dear Customer, We have detected unusual activity..."
|
| 69 |
|
| 70 |
sample_not_spam_positive = """
|
| 71 |
+
Subject: Great Experience with HKTV Mall!
|
| 72 |
+
Dear HKTV Mall Team,
|
| 73 |
+
I just received my order #HKTV-123456, and I’m really impressed with the fast delivery and quality of the products! Thanks for making my shopping experience so smooth. Keep up the great work!
|
| 74 |
+
Best regards,
|
| 75 |
+
Emily
|
| 76 |
"""
|
| 77 |
+
positive_snippet = "Subject: Great Experience with HKTV Mall! Dear HKTV Mall Team, I just received my order..."
|
| 78 |
|
| 79 |
sample_not_spam_negative = """
|
| 80 |
Subject: Issue with Recent Delivery
|
|
|
|
| 176 |
st.session_state.result_type = result_type
|
| 177 |
else:
|
| 178 |
st.session_state.result = "Please enter an email body or select a sample to analyze."
|
| 179 |
+
st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|