AIEcosystem commited on
Commit
7fc2f6f
·
verified ·
1 Parent(s): 3ff126b

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +14 -11
src/streamlit_app.py CHANGED
@@ -12,6 +12,7 @@ from streamlit_extras.stylable_container import stylable_container
12
  from typing import Optional
13
  from gliner import GLiNER
14
  from comet_ml import Experiment
 
15
  st.markdown(
16
  """
17
  <style>
@@ -63,13 +64,13 @@ st.link_button("by nlpblogs", "https://nlpblogs.com", type="tertiary")
63
  expander = st.expander("**Important notes**")
64
  expander.write("""**Named Entities:** This Business Core web app 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"
65
 
66
- 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.
67
 
68
- **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.
69
 
70
- **Usage Limits:** You can request results unlimited times for one (1) month.
71
 
72
- **Supported Languages:** English
73
 
74
  **Technical issues:** If your connection times out, please refresh the page or reopen the app's URL.
75
 
@@ -132,12 +133,12 @@ def clear_text():
132
  st.button("Clear text", on_click=clear_text)
133
  # --- Results Section ---
134
  if st.button("Results"):
135
- start_time = time.time()
136
  if not text.strip():
137
  st.warning("Please enter some text to extract entities.")
138
  elif word_count > word_limit:
139
  st.warning(f"Your text exceeds the {word_limit} word limit. Please shorten it to continue.")
140
  else:
 
141
  with st.spinner("Extracting entities...", show_time=True):
142
  entities = model.predict_entities(text, labels)
143
  df = pd.DataFrame(entities)
@@ -242,10 +243,12 @@ if st.button("Results"):
242
  if comet_initialized:
243
  experiment.log_figure(figure=fig_treemap, figure_name="entity_treemap_categories")
244
  experiment.end()
 
 
 
 
 
 
 
245
  else: # If df is empty
246
- st.warning("No entities were found in the provided text.")
247
- end_time = time.time()
248
- elapsed_time = end_time - start_time
249
- st.text("")
250
- st.text("")
251
- st.info(f"Results processed in **{elapsed_time:.2f} seconds**.")
 
12
  from typing import Optional
13
  from gliner import GLiNER
14
  from comet_ml import Experiment
15
+
16
  st.markdown(
17
  """
18
  <style>
 
64
  expander = st.expander("**Important notes**")
65
  expander.write("""**Named Entities:** This Business Core web app 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"
66
 
67
+ 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.
68
 
69
+ **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.
70
 
71
+ **Usage Limits:** You can request results unlimited times for one (1) month.
72
 
73
+ **Supported Languages:** English
74
 
75
  **Technical issues:** If your connection times out, please refresh the page or reopen the app's URL.
76
 
 
133
  st.button("Clear text", on_click=clear_text)
134
  # --- Results Section ---
135
  if st.button("Results"):
 
136
  if not text.strip():
137
  st.warning("Please enter some text to extract entities.")
138
  elif word_count > word_limit:
139
  st.warning(f"Your text exceeds the {word_limit} word limit. Please shorten it to continue.")
140
  else:
141
+ start_time = time.time()
142
  with st.spinner("Extracting entities...", show_time=True):
143
  entities = model.predict_entities(text, labels)
144
  df = pd.DataFrame(entities)
 
243
  if comet_initialized:
244
  experiment.log_figure(figure=fig_treemap, figure_name="entity_treemap_categories")
245
  experiment.end()
246
+
247
+ # These lines are moved to the correct location
248
+ end_time = time.time()
249
+ elapsed_time = end_time - start_time
250
+ st.text("")
251
+ st.text("")
252
+ st.info(f"Results processed in **{elapsed_time:.2f} seconds**.")
253
  else: # If df is empty
254
+ st.warning("No entities were found in the provided text.")