cleopatro commited on
Commit
acd9448
β€’
1 Parent(s): cfba6ea

add some data visualisations

Browse files
Files changed (1) hide show
  1. stream_lit.py +27 -8
stream_lit.py CHANGED
@@ -1,17 +1,16 @@
1
  import streamlit as st
2
- # from main import make_output
3
- # from summarization import make_summary
4
  import textrazor
5
  from dotenv import load_dotenv
6
  import os
7
  import pandas as pd
8
  import replicate
9
-
10
 
11
  load_dotenv()
12
  REPLICATE_API_TOKEN = os.getenv("REPLICATE_API_TOKEN")
13
 
14
- # text_ = """Alice: Hi there, is this Bob?
15
  # Bob: Yes, speaking. Who's calling?
16
  # Alice: Hey Bob, it's Alice from Acme Inc. We met at the conference last month.
17
  # Bob: Oh, hey Alice! Good to hear from you. How can I help you today?
@@ -54,23 +53,43 @@ def make_output(text:str):
54
  # df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)
55
  df = pd.concat([df, df2], ignore_index=True)
56
  # print(entity.id)
57
- df = df.drop_duplicates()
 
58
  return(df)
59
 
60
  st.title("CultureScout NLP Tool πŸ€–")
61
 
62
  # taking user inputs for context search
63
- st.write("Enter Text You Need Help With:")
64
  user_input = st.text_input("Text Here:", "")
65
 
66
  if st.button("πŸ”Ž Search It!"):
67
  def predict_sentiment(data:str):
68
  ans = make_output(user_input)
69
  return ans
70
- st.table(predict_sentiment(user_input))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  # taking user inputs for summarization
73
- st.write("Enter Text You Need to Summarize:")
74
  user_input1 = st.text_area("Text Here:", "")
75
 
76
  if st.button("πŸͺ„ Summarize"):
 
1
  import streamlit as st
2
+ from collections import Counter
 
3
  import textrazor
4
  from dotenv import load_dotenv
5
  import os
6
  import pandas as pd
7
  import replicate
8
+ import plotly.express as px
9
 
10
  load_dotenv()
11
  REPLICATE_API_TOKEN = os.getenv("REPLICATE_API_TOKEN")
12
 
13
+ text_ = """Alice: Hi there, is this Bob?
14
  # Bob: Yes, speaking. Who's calling?
15
  # Alice: Hey Bob, it's Alice from Acme Inc. We met at the conference last month.
16
  # Bob: Oh, hey Alice! Good to hear from you. How can I help you today?
 
53
  # df = pd.concat([df, pd.DataFrame([new_row])], ignore_index=True)
54
  df = pd.concat([df, df2], ignore_index=True)
55
  # print(entity.id)
56
+ df1 = df.drop_duplicates()
57
+
58
  return(df)
59
 
60
  st.title("CultureScout NLP Tool πŸ€–")
61
 
62
  # taking user inputs for context search
63
+ st.write("***Enter Text You Need Help With:***")
64
  user_input = st.text_input("Text Here:", "")
65
 
66
  if st.button("πŸ”Ž Search It!"):
67
  def predict_sentiment(data:str):
68
  ans = make_output(user_input)
69
  return ans
70
+ df = predict_sentiment(user_input)
71
+ df = df.drop_duplicates()
72
+ st.table(df)
73
+
74
+ id_df = predict_sentiment(user_input)['id']
75
+ id_freq = id_df.value_counts()
76
+ most_common_id = id_df.value_counts().index[0]
77
+
78
+ type_df = predict_sentiment(user_input)['type']
79
+ type_freq = type_df.value_counts()
80
+ most_common_type = type_df.value_counts().index[0]
81
+
82
+
83
+ st.bar_chart(id_freq)
84
+ st.bar_chart(type_freq)
85
+
86
+ st.write(f"Most appeared id is {most_common_id}.")
87
+ st.write(f"Most appeared type is {most_common_type}.")
88
+ st.write("""
89
+ """)
90
 
91
  # taking user inputs for summarization
92
+ st.write("***Enter Text You Need to Summarize:***")
93
  user_input1 = st.text_area("Text Here:", "")
94
 
95
  if st.button("πŸͺ„ Summarize"):