AIEcosystem commited on
Commit
39955bd
·
verified ·
1 Parent(s): b8ea1cf

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +51 -29
src/streamlit_app.py CHANGED
@@ -15,47 +15,59 @@ from gliner import GLiNER
15
  from comet_ml import Experiment
16
 
17
  # --- Page Configuration and UI Elements ---
18
- st.set_page_config(layout="wide", page_title="Combined NLP App")
19
- st.subheader("Combined NLP App", divider="green")
20
  st.link_button("by nlpblogs", "https://nlpblogs.com", type="tertiary")
21
 
 
22
  st.markdown(
23
  """
24
  <style>
 
25
  .stApp {
26
- background-color: #F5FFFA;
27
- color: #000000;
28
  }
 
29
  .css-1d36184 {
30
- background-color: #B2F2B2;
31
  secondary-background-color: #B2F2B2;
32
  }
33
- .streamlit-expanderContent {
34
- background-color: #F5FFFA;
35
- }
36
- .streamlit-expanderHeader {
37
  background-color: #F5FFFA;
38
  }
 
39
  .stTextArea textarea {
40
- background-color: #D4F4D4;
41
- color: #000000;
42
  }
 
43
  .stTextInput input {
44
- background-color: #B39DDB;
45
- color: #1A0A26;
46
  }
 
47
  .stButton > button {
48
  background-color: #D4F4D4;
49
  color: #000000;
50
  }
 
51
  .stAlert.st-warning {
52
- background-color: #C8F0C8;
53
  color: #000000;
54
  }
 
55
  .stAlert.st-success {
56
- background-color: #C8F0C8;
57
  color: #000000;
58
  }
 
 
 
 
 
 
59
  .stTabs [data-baseweb="tab-list"] button [data-testid="stMarkdownContainer"] p {
60
  font-size: 1.25rem;
61
  }
@@ -64,14 +76,24 @@ st.markdown(
64
  unsafe_allow_html=True
65
  )
66
 
67
- expander = st.expander("**Important notes**")
68
- expander.write("""
69
- This application combines two NLP tools in one place:
70
- - **HR.ai**: Specializes in extracting 36 predefined HR-related entities from your text.
71
- - **InfoFinder**: Answers custom wh-questions by finding relevant entities in your text.
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
- Both tools feature interactive visualizations and data download options.
74
- """)
75
 
76
  with st.sidebar:
77
  st.write("Use the following code to embed the web app on your website. Feel free to adjust the width and height values to fit your page.")
@@ -141,10 +163,10 @@ def get_stable_color(label):
141
  return '#' + hex_dig[:6]
142
 
143
  # --- Main App with Tabs ---
144
- tab1, tab2 = st.tabs(["HR.ai (Named Entity Recognition)", "InfoFinder (Question-Answering)"])
145
 
146
  with tab1:
147
- st.markdown("### HR.ai: Named Entity Recognition")
148
 
149
  # Load model for this tab
150
  model_hr = load_gliner_model("HR_AI")
@@ -194,7 +216,7 @@ with tab1:
194
  ''')
195
  st.divider()
196
 
197
- st.subheader("Tree map", divider="green")
198
  fig_treemap = px.treemap(df, path=[px.Constant("all"), 'category', 'label', 'text'], values='score', color='category')
199
  fig_treemap.update_layout(margin=dict(t=50, l=25, r=25, b=25), paper_bgcolor='#F5FFFA', plot_bgcolor='#F5FFFA')
200
  st.plotly_chart(fig_treemap)
@@ -255,7 +277,7 @@ with tab1:
255
  st.info(f"Results processed in **{elapsed_time:.2f} seconds**.")
256
 
257
  with tab2:
258
- st.markdown("### InfoFinder: Question-Answering")
259
 
260
  # Load model for this tab
261
  model_qa = load_gliner_model("InfoFinder")
@@ -281,7 +303,7 @@ with tab2:
281
  st.warning("Please enter a question.")
282
 
283
  st.markdown("---")
284
- st.subheader("Record of Questions", divider="violet")
285
 
286
  if st.session_state.user_labels:
287
  for i, label in enumerate(st.session_state.user_labels):
@@ -321,10 +343,10 @@ with tab2:
321
  df2 = df1[['label', 'text', 'score']]
322
  df = df2.rename(columns={'label': 'question', 'text': 'answer'})
323
 
324
- st.subheader("Extracted Answers", divider="violet")
325
  st.dataframe(df, use_container_width=True)
326
 
327
- st.subheader("Tree map", divider="violet")
328
  all_labels = df['question'].unique()
329
  label_color_map = {label: get_stable_color(label) for label in all_labels}
330
  fig_treemap = px.treemap(df, path=[px.Constant("all"), 'question', 'answer'], values='score', color='question', color_discrete_map=label_color_map)
 
15
  from comet_ml import Experiment
16
 
17
  # --- Page Configuration and UI Elements ---
18
+ st.set_page_config(layout="wide", page_title="NER")
19
+ st.subheader("HR.ai", divider="green")
20
  st.link_button("by nlpblogs", "https://nlpblogs.com", type="tertiary")
21
 
22
+
23
  st.markdown(
24
  """
25
  <style>
26
+ /* Main app background and text color */
27
  .stApp {
28
+ background-color: #F5FFFA; /* Mint cream, a very light green */
29
+ color: #000000; /* Black for the text */
30
  }
31
+ /* Sidebar background color */
32
  .css-1d36184 {
33
+ background-color: #B2F2B2; /* A pale green for the sidebar */
34
  secondary-background-color: #B2F2B2;
35
  }
36
+ /* Expander background color and header */
37
+ .streamlit-expanderContent, .streamlit-expanderHeader {
 
 
38
  background-color: #F5FFFA;
39
  }
40
+ /* Text Area background and text color */
41
  .stTextArea textarea {
42
+ background-color: #D4F4D4; /* A light, soft green */
43
+ color: #000000; /* Black for text */
44
  }
45
+ /* Text Input background and text color */
46
  .stTextInput input {
47
+ background-color: #D4F4D4; /* Same as the text area for consistency */
48
+ color: #000000;
49
  }
50
+ /* Button background and text color */
51
  .stButton > button {
52
  background-color: #D4F4D4;
53
  color: #000000;
54
  }
55
+ /* Warning box background and text color */
56
  .stAlert.st-warning {
57
+ background-color: #C8F0C8; /* A light green for the warning box */
58
  color: #000000;
59
  }
60
+ /* Success box background and text color */
61
  .stAlert.st-success {
62
+ background-color: #C8F0C8; /* A light green for the success box */
63
  color: #000000;
64
  }
65
+ /* Tab color when active */
66
+ .stTabs [data-baseweb="tab-list"] button[aria-selected="true"] {
67
+ background-color: #D4F4D4;
68
+ color: #000000;
69
+ }
70
+ /* Tab font size */
71
  .stTabs [data-baseweb="tab-list"] button [data-testid="stMarkdownContainer"] p {
72
  font-size: 1.25rem;
73
  }
 
76
  unsafe_allow_html=True
77
  )
78
 
79
+ expander.write("""**Named Entities:** This HR.ai web app predicts thirty-six (37) labels: "Job_with_Date", "Email", "Phone_number", "Street_address", "City", "Country", "Date_of_birth", "Marital_status", "Person", "Full_time", "Part_time", "Contract", "Terminated", "Retired", "Job_title", "Date", "Organization", "Role", "Performance_score", "Leave_of_absence", "Retirement_plan", "Bonus", "Stock_options", "Health_insurance", "Pay_rate", "Annual_salary", "Tax", "Deductions", "Interview_type", "Applicant", "Referral", "Job_board", "Recruiter", "Offer_letter", "Agreement", "Certification", "Skill"
80
+
81
+ 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.
82
+
83
+ **How to Use:**
84
+ 1. 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.
85
+ 2. Type or paste your text into the text area below, then press Ctrl + Enter.
86
+ 3. Click the 'Add Question' button to add your question to the Record of Questions. You can manage your questions by deleting them one by one.
87
+ 4. Click the 'Extract Answers' button to extract the answer to your question.
88
+
89
+ **Usage Limits:** You can request results unlimited times for one (1) month.
90
+
91
+ **Supported Languages:** English
92
+
93
+ **Technical issues:** If your connection times out, please refresh the page or reopen the app's URL.
94
+
95
+ For any errors or inquiries, please contact us at info@nlpblogs.com""")
96
 
 
 
97
 
98
  with st.sidebar:
99
  st.write("Use the following code to embed the web app on your website. Feel free to adjust the width and height values to fit your page.")
 
163
  return '#' + hex_dig[:6]
164
 
165
  # --- Main App with Tabs ---
166
+ tab1, tab2 = st.tabs(["HR.ai", "InfoFinder"])
167
 
168
  with tab1:
169
+ st.subheader("HR.ai")
170
 
171
  # Load model for this tab
172
  model_hr = load_gliner_model("HR_AI")
 
216
  ''')
217
  st.divider()
218
 
219
+ st.subheader("Candidate Card", divider="green")
220
  fig_treemap = px.treemap(df, path=[px.Constant("all"), 'category', 'label', 'text'], values='score', color='category')
221
  fig_treemap.update_layout(margin=dict(t=50, l=25, r=25, b=25), paper_bgcolor='#F5FFFA', plot_bgcolor='#F5FFFA')
222
  st.plotly_chart(fig_treemap)
 
277
  st.info(f"Results processed in **{elapsed_time:.2f} seconds**.")
278
 
279
  with tab2:
280
+ st.subheader("InfoFinder")
281
 
282
  # Load model for this tab
283
  model_qa = load_gliner_model("InfoFinder")
 
303
  st.warning("Please enter a question.")
304
 
305
  st.markdown("---")
306
+ st.subheader("Record of Questions", divider="green")
307
 
308
  if st.session_state.user_labels:
309
  for i, label in enumerate(st.session_state.user_labels):
 
343
  df2 = df1[['label', 'text', 'score']]
344
  df = df2.rename(columns={'label': 'question', 'text': 'answer'})
345
 
346
+ st.subheader("Extracted Answers", divider="green")
347
  st.dataframe(df, use_container_width=True)
348
 
349
+ st.subheader("Tree map", divider="green")
350
  all_labels = df['question'].unique()
351
  label_color_map = {label: get_stable_color(label) for label in all_labels}
352
  fig_treemap = px.treemap(df, path=[px.Constant("all"), 'question', 'answer'], values='score', color='question', color_discrete_map=label_color_map)