AIEcosystem commited on
Commit
0264672
·
verified ·
1 Parent(s): bdb7d95

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +39 -28
src/streamlit_app.py CHANGED
@@ -19,40 +19,47 @@ st.markdown(
19
  <style>
20
  /* Main app background and text color */
21
  .stApp {
22
- background-color: #FFF8F0; /* A very light, creamy orange */
23
  color: #000000; /* Black for text */
24
  }
 
25
  /* Sidebar background color */
26
  .css-1d36184 {
27
- background-color: #FFC080; /* A soft orange for the sidebar */
28
- secondary-background-color: #FFC080;
29
  }
 
30
  /* Expander background color */
31
  .streamlit-expanderContent {
32
- background-color: #FFF8F0;
33
  }
 
34
  /* Expander header background color */
35
  .streamlit-expanderHeader {
36
- background-color: #FFF8F0;
37
  }
 
38
  /* Text Area background and text color */
39
  .stTextArea textarea {
40
- background-color: #FFDDAA; /* A light, soft orange */
41
  color: #000000; /* Black for text */
42
  }
 
43
  /* Button background and text color */
44
  .stButton > button {
45
- background-color: #FFDDAA;
46
  color: #000000;
47
  }
 
48
  /* Warning box background and text color */
49
  .stAlert.st-warning {
50
- background-color: #FFBB88; /* A slightly darker orange for warnings */
51
  color: #000000;
52
  }
 
53
  /* Success box background and text color */
54
  .stAlert.st-success {
55
- background-color: #FFBB88; /* A slightly darker orange for success boxes */
56
  color: #000000;
57
  }
58
  </style>
@@ -63,24 +70,27 @@ st.markdown(
63
 
64
 
65
 
66
-
67
-
68
-
69
  # --- Page Configuration and UI Elements ---
70
  st.set_page_config(layout="wide", page_title="Named Entity Recognition App")
71
- st.subheader("Uncover", divider="orange")
72
  st.link_button("by nlpblogs", "https://nlpblogs.com", type="tertiary")
73
  expander = st.expander("**Important notes**")
74
- expander.write("""**Named Entities:** This Business Core predicts twenty-six (26) labels: "Person", "Contact", "Company", "Department", "Vendor", "Client", "Office", "Warehouse", "Address", "City", "State", "Country", "Date", "Time", "Time Period", "Revenue", "Cost", "Budget", "Invoice Number", "Product", "Service", "Task", "Project", "Status", "Asset", "Transaction"
 
75
  Results are presented in easy-to-read tables, visualized in an interactive tree map, pie chart and bar chart, and are available for download along with a Glossary of tags.
 
76
  **How to Use:** Type or paste your text into the text area below, then press Ctrl + Enter. Click the 'Results' button to extract and tag entities in your text data.
 
77
  **Usage Limits:** You can request results unlimited times for one (1) month.
 
78
  **Supported Languages:** English
 
79
  **Technical issues:** If your connection times out, please refresh the page or reopen the app's URL.
 
80
  For any errors or inquiries, please contact us at [email protected]""")
81
 
82
  with st.sidebar:
83
- st.write("Use the following code to embed the Business Core web app on your website. Feel free to adjust the width and height values to fit your page.")
84
  code = '''
85
  <iframe
86
  src="https://aiecosystem-business-core.hf.space"
@@ -93,7 +103,7 @@ with st.sidebar:
93
  st.text("")
94
  st.text("")
95
  st.divider()
96
- st.subheader("🚀 Ready to build your own NER Web App?", divider="orange")
97
  st.link_button("NER Builder", "https://nlpblogs.com", type="primary")
98
 
99
  # --- Comet ML Setup ---
@@ -207,7 +217,7 @@ if st.button("Results"):
207
  experiment.log_parameter("input_text", text)
208
  experiment.log_table("predicted_entities", df)
209
 
210
- st.subheader("Grouped Entities by Category", divider = "orange")
211
 
212
  # Create tabs for each category
213
  category_names = sorted(list(category_mapping.keys()))
@@ -235,9 +245,10 @@ if st.button("Results"):
235
  st.divider()
236
 
237
  # Tree map
238
- st.subheader("Tree map", divider = "orange")
239
  fig_treemap = px.treemap(df, path=[px.Constant("all"), 'category', 'label', 'text'], values='score', color='category')
240
- fig_treemap.update_layout(margin=dict(t=50, l=25, r=25, b=25), paper_bgcolor='#FFF8F0', plot_bgcolor='#FFF8F0')
 
241
  st.plotly_chart(fig_treemap)
242
 
243
  # Pie and Bar charts
@@ -246,26 +257,26 @@ if st.button("Results"):
246
  col1, col2 = st.columns(2)
247
 
248
  with col1:
249
- st.subheader("Pie chart", divider = "orange")
250
  fig_pie = px.pie(grouped_counts, values='count', names='category', hover_data=['count'], labels={'count': 'count'}, title='Percentage of predicted categories')
251
  fig_pie.update_traces(textposition='inside', textinfo='percent+label')
252
  fig_pie.update_layout(
253
- paper_bgcolor='#FFF8F0',
254
- plot_bgcolor='#FFF8F0'
255
  )
256
  st.plotly_chart(fig_pie)
257
 
258
  with col2:
259
- st.subheader("Bar chart", divider = "orange")
260
  fig_bar = px.bar(grouped_counts, x="count", y="category", color="category", text_auto=True, title='Occurrences of predicted categories')
261
  fig_bar.update_layout(
262
- paper_bgcolor='#FFF8F0',
263
- plot_bgcolor='#FFF8F0'
264
  )
265
  st.plotly_chart(fig_bar)
266
 
267
  # Most Frequent Entities
268
- st.subheader("Most Frequent Entities", divider="orange")
269
  word_counts = df['text'].value_counts().reset_index()
270
  word_counts.columns = ['Entity', 'Count']
271
  repeating_entities = word_counts[word_counts['Count'] > 1]
@@ -273,8 +284,8 @@ if st.button("Results"):
273
  st.dataframe(repeating_entities, use_container_width=True)
274
  fig_repeating_bar = px.bar(repeating_entities, x='Entity', y='Count', color='Entity')
275
  fig_repeating_bar.update_layout(xaxis={'categoryorder': 'total descending'},
276
- paper_bgcolor='#FFF8F0',
277
- plot_bgcolor='#FFF8F0')
278
  st.plotly_chart(fig_repeating_bar)
279
  else:
280
  st.warning("No entities were found that occur more than once.")
 
19
  <style>
20
  /* Main app background and text color */
21
  .stApp {
22
+ background-color: #FFE5E5; /* A very light red */
23
  color: #000000; /* Black for text */
24
  }
25
+
26
  /* Sidebar background color */
27
  .css-1d36184 {
28
+ background-color: #FF6B6B; /* A soft red for the sidebar */
29
+ secondary-background-color: #FF6B6B;
30
  }
31
+
32
  /* Expander background color */
33
  .streamlit-expanderContent {
34
+ background-color: #FFE5E5;
35
  }
36
+
37
  /* Expander header background color */
38
  .streamlit-expanderHeader {
39
+ background-color: #FFE5E5;
40
  }
41
+
42
  /* Text Area background and text color */
43
  .stTextArea textarea {
44
+ background-color: #FF9999; /* A light red */
45
  color: #000000; /* Black for text */
46
  }
47
+
48
  /* Button background and text color */
49
  .stButton > button {
50
+ background-color: #FF9999;
51
  color: #000000;
52
  }
53
+
54
  /* Warning box background and text color */
55
  .stAlert.st-warning {
56
+ background-color: #FF4D4D; /* A slightly darker red for warnings */
57
  color: #000000;
58
  }
59
+
60
  /* Success box background and text color */
61
  .stAlert.st-success {
62
+ background-color: #FF4D4D; /* A slightly darker red for success boxes */
63
  color: #000000;
64
  }
65
  </style>
 
70
 
71
 
72
 
 
 
 
73
  # --- Page Configuration and UI Elements ---
74
  st.set_page_config(layout="wide", page_title="Named Entity Recognition App")
75
+ st.subheader("Uncover", divider="red")
76
  st.link_button("by nlpblogs", "https://nlpblogs.com", type="tertiary")
77
  expander = st.expander("**Important notes**")
78
+ expander.write("""**Named Entities:** This Uncover predicts twenty-eight (28) labels: "Names", "Aliases", "Identifiers", "Roles", "Government_agencies", "Businesses", "Criminal_groups", "Financial_institutions", "Addresses", "Geographic_coordinates", "Landmarks", "Jurisdictions", "Dates", "Timestamps", "Time_ranges", "Weapons", "Vehicles", "Financial_information", "Evidence", "Relationships", "Demographics", "Biometrics", "Psychological_states", "Software_types", "Hardware_components", "Equipment", "Events", "Activities"
79
+
80
  Results are presented in easy-to-read tables, visualized in an interactive tree map, pie chart and bar chart, and are available for download along with a Glossary of tags.
81
+
82
  **How to Use:** Type or paste your text into the text area below, then press Ctrl + Enter. Click the 'Results' button to extract and tag entities in your text data.
83
+
84
  **Usage Limits:** You can request results unlimited times for one (1) month.
85
+
86
  **Supported Languages:** English
87
+
88
  **Technical issues:** If your connection times out, please refresh the page or reopen the app's URL.
89
+
90
  For any errors or inquiries, please contact us at [email protected]""")
91
 
92
  with st.sidebar:
93
+ st.write("Use the following code to embed the Uncover web app on your website. Feel free to adjust the width and height values to fit your page.")
94
  code = '''
95
  <iframe
96
  src="https://aiecosystem-business-core.hf.space"
 
103
  st.text("")
104
  st.text("")
105
  st.divider()
106
+ st.subheader("🚀 Ready to build your own NER Web App?", divider="red")
107
  st.link_button("NER Builder", "https://nlpblogs.com", type="primary")
108
 
109
  # --- Comet ML Setup ---
 
217
  experiment.log_parameter("input_text", text)
218
  experiment.log_table("predicted_entities", df)
219
 
220
+ st.subheader("Grouped Entities by Category", divider = "red")
221
 
222
  # Create tabs for each category
223
  category_names = sorted(list(category_mapping.keys()))
 
245
  st.divider()
246
 
247
  # Tree map
248
+ st.subheader("Tree map", divider = "red")
249
  fig_treemap = px.treemap(df, path=[px.Constant("all"), 'category', 'label', 'text'], values='score', color='category')
250
+ fig_treemap.update_layout(margin=dict(t=50, l=25, r=25, b=25), paper_bgcolor='#FFE5E5', plot_bgcolor='#FFE5E5')
251
+
252
  st.plotly_chart(fig_treemap)
253
 
254
  # Pie and Bar charts
 
257
  col1, col2 = st.columns(2)
258
 
259
  with col1:
260
+ st.subheader("Pie chart", divider = "red")
261
  fig_pie = px.pie(grouped_counts, values='count', names='category', hover_data=['count'], labels={'count': 'count'}, title='Percentage of predicted categories')
262
  fig_pie.update_traces(textposition='inside', textinfo='percent+label')
263
  fig_pie.update_layout(
264
+ paper_bgcolor='#FFE5E5',
265
+ plot_bgcolor='#FFE5E5'
266
  )
267
  st.plotly_chart(fig_pie)
268
 
269
  with col2:
270
+ st.subheader("Bar chart", divider = "red")
271
  fig_bar = px.bar(grouped_counts, x="count", y="category", color="category", text_auto=True, title='Occurrences of predicted categories')
272
  fig_bar.update_layout(
273
+ paper_bgcolor='#FFE5E5',
274
+ plot_bgcolor='#FFE5E5'
275
  )
276
  st.plotly_chart(fig_bar)
277
 
278
  # Most Frequent Entities
279
+ st.subheader("Most Frequent Entities", divider="red")
280
  word_counts = df['text'].value_counts().reset_index()
281
  word_counts.columns = ['Entity', 'Count']
282
  repeating_entities = word_counts[word_counts['Count'] > 1]
 
284
  st.dataframe(repeating_entities, use_container_width=True)
285
  fig_repeating_bar = px.bar(repeating_entities, x='Entity', y='Count', color='Entity')
286
  fig_repeating_bar.update_layout(xaxis={'categoryorder': 'total descending'},
287
+ paper_bgcolor='#FFE5E5',
288
+ plot_bgcolor='#FFE5E5')
289
  st.plotly_chart(fig_repeating_bar)
290
  else:
291
  st.warning("No entities were found that occur more than once.")