Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,11 +6,16 @@ import pandas as pd
|
|
| 6 |
|
| 7 |
|
| 8 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
st.title("WhatsApp Analysis Tool")
|
| 10 |
st.markdown("This app summarizes Whatsapp chats and provides named entity recognition as well as sentiment analysis for the conversation")
|
| 11 |
st.markdown("**NOTE**: *This app can only receive chats downloaded from IOS as the downloaded chat format is different than from Android.*")
|
| 12 |
st.markdown("Download your whatsapp chat by going to Settings > Chats > Export Chat and there select the chat you want to summarize (download 'Without Media').")
|
| 13 |
-
|
| 14 |
|
| 15 |
# File uploader
|
| 16 |
uploaded_file = st.file_uploader("Choose a file (.zip)", type=['zip'])
|
|
@@ -32,45 +37,25 @@ def main():
|
|
| 32 |
st.markdown(f"```\n{text_for_analysis}\n```", unsafe_allow_html=True)
|
| 33 |
process = st.button('Process')
|
| 34 |
if process:
|
| 35 |
-
#
|
| 36 |
-
tokenizer_sentiment, model_sentiment
|
| 37 |
-
tokenizer_summary, model_summary
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
# Display results
|
| 51 |
-
st.subheader("Sentiment Analysis")
|
| 52 |
-
st.write("Sentiment:", sentiment)
|
| 53 |
-
|
| 54 |
-
st.subheader("Summary")
|
| 55 |
-
st.write("Summary:", summary)
|
| 56 |
-
|
| 57 |
-
st.subheader("Named Entity Recognition")
|
| 58 |
-
ner_df = pd.DataFrame(ner_results, columns=["Word", "Entity Group"])
|
| 59 |
-
st.write(ner_df)
|
| 60 |
else:
|
| 61 |
st.error("Unsupported file type. Please upload a .txt or .zip file.")
|
| 62 |
else:
|
| 63 |
st.info("Please upload a file to proceed.")
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|
| 66 |
-
main()
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
def main():
|
| 9 |
+
# Load models
|
| 10 |
+
tokenizer_sentiment, model_sentiment = load_sentiment_analyzer()
|
| 11 |
+
tokenizer_summary, model_summary = load_summarizer()
|
| 12 |
+
pipe_ner = load_NER()
|
| 13 |
+
|
| 14 |
st.title("WhatsApp Analysis Tool")
|
| 15 |
st.markdown("This app summarizes Whatsapp chats and provides named entity recognition as well as sentiment analysis for the conversation")
|
| 16 |
st.markdown("**NOTE**: *This app can only receive chats downloaded from IOS as the downloaded chat format is different than from Android.*")
|
| 17 |
st.markdown("Download your whatsapp chat by going to Settings > Chats > Export Chat and there select the chat you want to summarize (download 'Without Media').")
|
| 18 |
+
|
| 19 |
|
| 20 |
# File uploader
|
| 21 |
uploaded_file = st.file_uploader("Choose a file (.zip)", type=['zip'])
|
|
|
|
| 37 |
st.markdown(f"```\n{text_for_analysis}\n```", unsafe_allow_html=True)
|
| 38 |
process = st.button('Process')
|
| 39 |
if process:
|
| 40 |
+
# Perform analysis
|
| 41 |
+
sentiment = get_sentiment_analysis(text_for_analysis, tokenizer_sentiment, model_sentiment)
|
| 42 |
+
summary = generate_summary(text_for_analysis, tokenizer_summary, model_summary)
|
| 43 |
+
ner_results = get_NER(text_for_analysis, pipe_ner)
|
| 44 |
+
|
| 45 |
+
# Display results
|
| 46 |
+
st.subheader("Sentiment Analysis")
|
| 47 |
+
st.write("Sentiment:", sentiment)
|
| 48 |
+
|
| 49 |
+
st.subheader("Summary")
|
| 50 |
+
st.write("Summary:", summary)
|
| 51 |
+
|
| 52 |
+
st.subheader("Named Entity Recognition")
|
| 53 |
+
ner_df = pd.DataFrame(ner_results, columns=["Word", "Entity Group"])
|
| 54 |
+
st.write(ner_df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
else:
|
| 56 |
st.error("Unsupported file type. Please upload a .txt or .zip file.")
|
| 57 |
else:
|
| 58 |
st.info("Please upload a file to proceed.")
|
| 59 |
|
| 60 |
if __name__ == "__main__":
|
| 61 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|