Update app.py
Browse files
app.py
CHANGED
|
@@ -79,8 +79,15 @@ t = translations[lang_code]
|
|
| 79 |
|
| 80 |
st.markdown(f"### {t['title']}")
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
# Text Input with instructions
|
| 83 |
-
sentence_input = st.text_area(t['input_label'], height=150, placeholder=t['input_placeholder'])
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
if st.button(t['analyze_button']):
|
| 86 |
if sentence_input:
|
|
@@ -112,6 +119,7 @@ if st.button(t['analyze_button']):
|
|
| 112 |
html = re.sub(r'<g [^>]*transform="translate\((\d+),(\d+)\)"', lambda m: f'<g transform="translate({m.group(1)},50)"', html)
|
| 113 |
st.write(html, unsafe_allow_html=True)
|
| 114 |
|
|
|
|
| 115 |
with st.expander(t['network_diagram'], expanded=True):
|
| 116 |
fig = visualize_syntax(sentence_input, nlp_models[lang_code], lang_code)
|
| 117 |
st.pyplot(fig)
|
|
|
|
| 79 |
|
| 80 |
st.markdown(f"### {t['title']}")
|
| 81 |
|
| 82 |
+
# Initialize session state for input text if it doesn't exist
|
| 83 |
+
if 'input_text' not in st.session_state:
|
| 84 |
+
st.session_state.input_text = ""
|
| 85 |
+
|
| 86 |
# Text Input with instructions
|
| 87 |
+
sentence_input = st.text_area(t['input_label'], height=150, placeholder=t['input_placeholder'], value=st.session_state.input_text)
|
| 88 |
+
|
| 89 |
+
# Update session state with current input
|
| 90 |
+
st.session_state.input_text = sentence_input
|
| 91 |
|
| 92 |
if st.button(t['analyze_button']):
|
| 93 |
if sentence_input:
|
|
|
|
| 119 |
html = re.sub(r'<g [^>]*transform="translate\((\d+),(\d+)\)"', lambda m: f'<g transform="translate({m.group(1)},50)"', html)
|
| 120 |
st.write(html, unsafe_allow_html=True)
|
| 121 |
|
| 122 |
+
# Network graph
|
| 123 |
with st.expander(t['network_diagram'], expanded=True):
|
| 124 |
fig = visualize_syntax(sentence_input, nlp_models[lang_code], lang_code)
|
| 125 |
st.pyplot(fig)
|