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