Spaces:
Runtime error
Runtime error
Move text input inside form
Browse files
app.py
CHANGED
@@ -21,18 +21,22 @@ def run() -> None:
|
|
21 |
ner_model_name="dslim/bert-base-NER",
|
22 |
)
|
23 |
st.title("📰 News Analyzer")
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
st.
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
)
|
33 |
-
button = st.button("Analyze")
|
34 |
-
if button:
|
35 |
-
predictions = analyzer(headline=headline, content=content)
|
36 |
col1, _, col2 = st.columns([2, 1, 4])
|
37 |
|
38 |
with col1:
|
@@ -53,12 +57,16 @@ def run() -> None:
|
|
53 |
with col2:
|
54 |
st.subheader("Headline:")
|
55 |
annotated_text(
|
56 |
-
*parse_entities(
|
|
|
|
|
57 |
)
|
58 |
st.subheader("Content:")
|
59 |
-
if content:
|
60 |
annotated_text(
|
61 |
-
*parse_entities(
|
|
|
|
|
62 |
)
|
63 |
else:
|
64 |
st.error("Content not provided.")
|
|
|
21 |
ner_model_name="dslim/bert-base-NER",
|
22 |
)
|
23 |
st.title("📰 News Analyzer")
|
24 |
+
with st.form("news-form", clear_on_submit=False):
|
25 |
+
st.session_state.headline = st.text_input("Headline:")
|
26 |
+
st.session_state.content = st.text_area("Content:", height=200)
|
27 |
+
st.session_state.button = st.form_submit_button("Analyze")
|
28 |
+
|
29 |
+
if "button" in st.session_state:
|
30 |
+
if st.session_state.headline == "":
|
31 |
+
st.error("Please, provide a headline.")
|
32 |
+
else:
|
33 |
+
if st.session_state.content == "":
|
34 |
+
st.warning(
|
35 |
+
"Please, provide both headline and content to achieve better results."
|
36 |
+
)
|
37 |
+
predictions = analyzer(
|
38 |
+
headline=st.session_state.headline, content=st.session_state.content
|
39 |
)
|
|
|
|
|
|
|
40 |
col1, _, col2 = st.columns([2, 1, 4])
|
41 |
|
42 |
with col1:
|
|
|
57 |
with col2:
|
58 |
st.subheader("Headline:")
|
59 |
annotated_text(
|
60 |
+
*parse_entities(
|
61 |
+
st.session_state.headline, predictions["ner"]["headline"]
|
62 |
+
)
|
63 |
)
|
64 |
st.subheader("Content:")
|
65 |
+
if st.session_state.content:
|
66 |
annotated_text(
|
67 |
+
*parse_entities(
|
68 |
+
st.session_state.content, predictions["ner"]["content"]
|
69 |
+
)
|
70 |
)
|
71 |
else:
|
72 |
st.error("Content not provided.")
|