JoshuaZywoo commited on
Commit
efa60b3
·
verified ·
1 Parent(s): c46fd4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # loarding pipeline
5
+ sentiment_analyzer = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
6
+ ner_tagger = pipeline("ner", model="dslim/bert-base-NER", grouped_entities=True)
7
+
8
+ st.set_page_config(page_title="Customer Support Analyzer", layout="centered")
9
+ st.title("📞 AI Customer service Dialogue Analysis")
10
+
11
+ # Customer type
12
+ user_input = st.text_area("Please enter the question or conversation:", height=150)
13
+
14
+ if st.button("Analyse"):
15
+ if user_input.strip() == "":
16
+ st.warning("Please enter content")
17
+ else:
18
+ with st.spinner("Analysing..."):
19
+ # Emotion
20
+ sentiment_result = sentiment_analyzer(user_input)[0]
21
+ st.subheader("📌 Sentiment analysis results")
22
+ st.write(f"**Emotional type**: {sentiment_result['label']}")
23
+ st.write(f"**Confidence degree**: {sentiment_result['score']:.2f}")
24
+
25
+ # Command
26
+ ner_results = ner_tagger(user_input)
27
+ extracted_entities = [ent['word'] for ent in ner_results if ent['score'] > 0.5]
28
+
29
+ st.subheader("🔍Problem keyword recognition")
30
+ if extracted_entities:
31
+ st.write(", ".join(set(extracted_entities)))
32
+ else:
33
+ st.write("The specific problem keywords were not identified")