Update app.py
Browse files
app.py
CHANGED
@@ -158,6 +158,14 @@ def process_model(target_word):
|
|
158 |
|
159 |
return fig, similar_words_text, dissimilar_words_text
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
# Gradio ์ธํฐํ์ด์ค ์์
|
163 |
with gr.Blocks(css=".plot-box {width: 70%; height: 500px;}") as iface:
|
@@ -167,9 +175,12 @@ with gr.Blocks(css=".plot-box {width: 70%; height: 500px;}") as iface:
|
|
167 |
download_nltk_library()
|
168 |
|
169 |
with gr.Row():
|
|
|
|
|
170 |
# ์ฌ์ฉ์ ์
๋ ฅ ๋ฐ์ค๋ฅผ ๊ฐ์กฐํ๊ธฐ ์ํด ์คํ์ผ์ ๋ณ๊ฒฝ
|
171 |
-
|
172 |
-
|
|
|
173 |
|
174 |
with gr.Row():
|
175 |
# ์๊ฐํ ํ๋ฉด์ ํฌ๊ธฐ๋ฅผ CSS๋ก ์ฆ๊ฐ
|
@@ -179,11 +190,29 @@ with gr.Blocks(css=".plot-box {width: 70%; height: 500px;}") as iface:
|
|
179 |
similar_words_output = gr.Textbox(label="์ ์ฌํ ๋จ์ด", interactive=False, lines=5)
|
180 |
dissimilar_words_output = gr.Textbox(label="์ ์ฌํ์ง ์์ ๋จ์ด", interactive=False, lines=5)
|
181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
submit_btn.click(
|
183 |
fn=process_model,
|
184 |
inputs=[word_input],
|
185 |
outputs=[plot_output, similar_words_output, dissimilar_words_output]
|
186 |
)
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
if __name__ == "__main__":
|
189 |
iface.launch()
|
|
|
158 |
|
159 |
return fig, similar_words_text, dissimilar_words_text
|
160 |
|
161 |
+
def change_button_state_true():
|
162 |
+
# If the first button is clicked, enable or disable the second button based on its state
|
163 |
+
return gr.update(interactive=True)
|
164 |
+
|
165 |
+
def change_button_state_false():
|
166 |
+
# If the first button is clicked, enable or disable the second button based on its state
|
167 |
+
return gr.update(interactive=False)
|
168 |
+
|
169 |
|
170 |
# Gradio ์ธํฐํ์ด์ค ์์
|
171 |
with gr.Blocks(css=".plot-box {width: 70%; height: 500px;}") as iface:
|
|
|
175 |
download_nltk_library()
|
176 |
|
177 |
with gr.Row():
|
178 |
+
word_input = gr.Textbox(label="**๊ฐ์กฐํ ๋จ์ด ์
๋ ฅ**", elem_id="input-box", placeholder="๋จ์ด๋ฅผ ์
๋ ฅํ์ธ์", lines=1, interactive=False)
|
179 |
+
with gr.Column(scale=1):
|
180 |
# ์ฌ์ฉ์ ์
๋ ฅ ๋ฐ์ค๋ฅผ ๊ฐ์กฐํ๊ธฐ ์ํด ์คํ์ผ์ ๋ณ๊ฒฝ
|
181 |
+
# word_input = gr.Textbox(label="**๊ฐ์กฐํ ๋จ์ด ์
๋ ฅ**", elem_id="input-box", placeholder="๋จ์ด๋ฅผ ์
๋ ฅํ์ธ์", lines=1)
|
182 |
+
load_btn = gr.Button("๋ชจ๋ธ ๋ก๋ง", elem_id="submit-btn")
|
183 |
+
submit_btn = gr.Button("๋จ์ด ์
๋ ฅ", elem_id="submit-btn", interactive=False)
|
184 |
|
185 |
with gr.Row():
|
186 |
# ์๊ฐํ ํ๋ฉด์ ํฌ๊ธฐ๋ฅผ CSS๋ก ์ฆ๊ฐ
|
|
|
190 |
similar_words_output = gr.Textbox(label="์ ์ฌํ ๋จ์ด", interactive=False, lines=5)
|
191 |
dissimilar_words_output = gr.Textbox(label="์ ์ฌํ์ง ์์ ๋จ์ด", interactive=False, lines=5)
|
192 |
|
193 |
+
load_btn.click(
|
194 |
+
fn=process_model,
|
195 |
+
inputs=[word_input],
|
196 |
+
outputs=[plot_output, similar_words_output, dissimilar_words_output]
|
197 |
+
)
|
198 |
+
load_btn.click(
|
199 |
+
fn=change_button_state_true,
|
200 |
+
outputs=submit_btn
|
201 |
+
)
|
202 |
+
load_btn.click(
|
203 |
+
fn=change_button_state_true,
|
204 |
+
outputs=word_input
|
205 |
+
)
|
206 |
submit_btn.click(
|
207 |
fn=process_model,
|
208 |
inputs=[word_input],
|
209 |
outputs=[plot_output, similar_words_output, dissimilar_words_output]
|
210 |
)
|
211 |
+
submit_btn.click(
|
212 |
+
fn=change_button_state_false,
|
213 |
+
outputs=load_btn
|
214 |
+
)
|
215 |
+
|
216 |
|
217 |
if __name__ == "__main__":
|
218 |
iface.launch()
|