AhmedTaha012 commited on
Commit
e89f604
1 Parent(s): 8d05dea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -18
app.py CHANGED
@@ -1,36 +1,30 @@
1
  import streamlit as st
2
  from transformers import pipeline
 
3
  sentiment_model = pipeline("text-classification", model="AhmedTaha012/managersFeedback-V1.0.7")
4
  increase_decrease_model = pipeline("text-classification", model="AhmedTaha012/nextQuarter-status-V1.1.9")
5
- ner_model = pipeline("token-classification", model="AhmedTaha012/finance-ner-v0.0.8-finetuned-ner")
6
 
7
  st.title("Transcript Analysis")
8
  transcript = st.text_area("Enter the transcript:", height=200)
 
 
 
9
 
10
  if st.button("Analyze"):
11
  st.subheader("Sentiment Analysis")
12
- sentiment = sentiment_model(transcript)[0]['label']
 
13
  sentiment_color = "green" if sentiment == "POSITIVE" else "red"
14
  st.markdown(f'<span style="color:{sentiment_color}">{sentiment}</span>', unsafe_allow_html=True)
15
 
16
  st.subheader("Increase/Decrease Prediction")
17
- increase_decrease = increase_decrease_model(transcript)[0]['label']
 
18
  increase_decrease_color = "green" if increase_decrease == "INCREASE" else "red"
19
  st.markdown(f'<span style="color:{increase_decrease_color}">{increase_decrease}</span>', unsafe_allow_html=True)
20
 
21
  st.subheader("NER Metrics")
22
- ner_result = ner_model(transcript)
23
- revenue = next((entity['entity'] for entity in ner_result if entity['entity'] == 'revenue'), None)
24
- if revenue:
25
- st.write(f"Revenue: {revenue}")
26
- else:
27
- st.write("Revenue not found.")
28
-
29
- show_details = st.checkbox("Show Detailed Predictions")
30
- if show_details:
31
- st.subheader("Detailed Predictions")
32
- st.json({
33
- "Sentiment Analysis": sentiment,
34
- "Increase/Decrease Prediction": increase_decrease,
35
- "NER Metrics": ner_result
36
- })
 
1
  import streamlit as st
2
  from transformers import pipeline
3
+ import math
4
  sentiment_model = pipeline("text-classification", model="AhmedTaha012/managersFeedback-V1.0.7")
5
  increase_decrease_model = pipeline("text-classification", model="AhmedTaha012/nextQuarter-status-V1.1.9")
6
+ ner_model = pipeline("token-classification", model="AhmedTaha012/finance-ner-v0.0.9-finetuned-ner")
7
 
8
  st.title("Transcript Analysis")
9
  transcript = st.text_area("Enter the transcript:", height=200)
10
+ tokens=transcript.split()
11
+ splitSize=256
12
+ chunks=[tokens[r*splitSize:(r+1)*splitSize] for r in range(math.ceil(len(tokens)/splitSize))]
13
 
14
  if st.button("Analyze"):
15
  st.subheader("Sentiment Analysis")
16
+ sentiment = [sentiment_model(x)[0]['label'] for x in chunks]
17
+ sentiment=max(sentiment,key=sentiment.count)
18
  sentiment_color = "green" if sentiment == "POSITIVE" else "red"
19
  st.markdown(f'<span style="color:{sentiment_color}">{sentiment}</span>', unsafe_allow_html=True)
20
 
21
  st.subheader("Increase/Decrease Prediction")
22
+ increase_decrease = [increase_decrease_model(x)[0]['label'] for x in chunks]
23
+ increase_decrease=max(increase_decrease,key=increase_decrease.count)
24
  increase_decrease_color = "green" if increase_decrease == "INCREASE" else "red"
25
  st.markdown(f'<span style="color:{increase_decrease_color}">{increase_decrease}</span>', unsafe_allow_html=True)
26
 
27
  st.subheader("NER Metrics")
28
+ ner_result = [ner_model(x) for x in chunks]
29
+ st.write(str(ner_result))
30
+