import streamlit as st
from transformers import pipeline
import math
sentiment_model = pipeline("text-classification", model="AhmedTaha012/managersFeedback-V1.0.7")
increase_decrease_model = pipeline("text-classification", model="AhmedTaha012/nextQuarter-status-V1.1.9")
ner_model = pipeline("token-classification", model="AhmedTaha012/finance-ner-v0.0.9-finetuned-ner")
st.title("Transcript Analysis")
transcript = st.text_area("Enter the transcript:", height=200)
tokens=transcript.split()
splitSize=256
chunks=[tokens[r*splitSize:(r+1)*splitSize] for r in range(math.ceil(len(tokens)/splitSize))]
if st.button("Analyze"):
st.subheader("Sentiment Analysis")
sentiment = [sentiment_model(x)[0]['label'] for x in chunks]
sentiment=max(sentiment,key=sentiment.count)
sentiment_color = "green" if sentiment == "POSITIVE" else "red"
st.markdown(f'{sentiment}', unsafe_allow_html=True)
st.subheader("Increase/Decrease Prediction")
increase_decrease = [increase_decrease_model(x)[0]['label'] for x in chunks]
increase_decrease=max(increase_decrease,key=increase_decrease.count)
increase_decrease_color = "green" if increase_decrease == "INCREASE" else "red"
st.markdown(f'{increase_decrease}', unsafe_allow_html=True)
st.subheader("NER Metrics")
ner_result = [ner_model(x) for x in chunks]
st.write(str(ner_result))