Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +7 -9
src/streamlit_app.py
CHANGED
|
@@ -13,7 +13,6 @@ from typing import Optional
|
|
| 13 |
from gliner import GLiNER
|
| 14 |
from comet_ml import Experiment
|
| 15 |
|
| 16 |
-
|
| 17 |
# --- Page Configuration and UI Elements ---
|
| 18 |
st.set_page_config(layout="wide", page_title="Named Entity Recognition App")
|
| 19 |
st.subheader("DataHarvest", divider="violet")
|
|
@@ -21,7 +20,11 @@ st.link_button("by nlpblogs", "https://nlpblogs.com", type="tertiary")
|
|
| 21 |
st.markdown(':rainbow[**Supported Languages: English**]')
|
| 22 |
|
| 23 |
expander = st.expander("**Important notes**")
|
| 24 |
-
expander.write("""**Named Entities:** This DataHarvest web app predicts nine (9) labels: "person", "country", "city", "organization", "date", "time", "cardinal", "money", "position"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
with st.sidebar:
|
| 27 |
st.write("Use the following code to embed the DataHarvest web app on your website. Feel free to adjust the width and height values to fit your page.")
|
|
@@ -89,11 +92,6 @@ def clear_text():
|
|
| 89 |
st.session_state.results_df = pd.DataFrame()
|
| 90 |
st.session_state.elapsed_time = 0.0
|
| 91 |
|
| 92 |
-
def remove_punctuation(text):
|
| 93 |
-
"""Removes punctuation from a string."""
|
| 94 |
-
translator = str.maketrans('', '', string.punctuation)
|
| 95 |
-
return text.translate(translator)
|
| 96 |
-
|
| 97 |
st.button("Clear text", on_click=clear_text)
|
| 98 |
|
| 99 |
# --- Results Section ---
|
|
@@ -111,8 +109,8 @@ if st.button("Results"):
|
|
| 111 |
st.session_state.last_text = text
|
| 112 |
start_time = time.time()
|
| 113 |
with st.spinner("Extracting entities...", show_time=True):
|
| 114 |
-
|
| 115 |
-
entities = model.predict_entities(
|
| 116 |
df = pd.DataFrame(entities)
|
| 117 |
st.session_state.results_df = df
|
| 118 |
if not df.empty:
|
|
|
|
| 13 |
from gliner import GLiNER
|
| 14 |
from comet_ml import Experiment
|
| 15 |
|
|
|
|
| 16 |
# --- Page Configuration and UI Elements ---
|
| 17 |
st.set_page_config(layout="wide", page_title="Named Entity Recognition App")
|
| 18 |
st.subheader("DataHarvest", divider="violet")
|
|
|
|
| 20 |
st.markdown(':rainbow[**Supported Languages: English**]')
|
| 21 |
|
| 22 |
expander = st.expander("**Important notes**")
|
| 23 |
+
expander.write("""**Named Entities:** This DataHarvest web app predicts nine (9) labels: "person", "country", "city", "organization", "date", "time", "cardinal", "money", "position"
|
| 24 |
+
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.
|
| 25 |
+
**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.
|
| 26 |
+
**Usage Limits:** You can request results unlimited times for one (1) month.
|
| 27 |
+
**Technical issues:** If your connection times out, please refresh the page or reopen the app's URL. For any errors or inquiries, please contact us at info@nlpblogs.com""")
|
| 28 |
|
| 29 |
with st.sidebar:
|
| 30 |
st.write("Use the following code to embed the DataHarvest web app on your website. Feel free to adjust the width and height values to fit your page.")
|
|
|
|
| 92 |
st.session_state.results_df = pd.DataFrame()
|
| 93 |
st.session_state.elapsed_time = 0.0
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
st.button("Clear text", on_click=clear_text)
|
| 96 |
|
| 97 |
# --- Results Section ---
|
|
|
|
| 109 |
st.session_state.last_text = text
|
| 110 |
start_time = time.time()
|
| 111 |
with st.spinner("Extracting entities...", show_time=True):
|
| 112 |
+
# Pass the raw text directly to the model
|
| 113 |
+
entities = model.predict_entities(text, labels)
|
| 114 |
df = pd.DataFrame(entities)
|
| 115 |
st.session_state.results_df = df
|
| 116 |
if not df.empty:
|