Ridealist commited on
Commit
0131a54
ยท
verified ยท
1 Parent(s): 7112f5e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -2
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
- word_input = gr.Textbox(label="**๊ฐ•์กฐํ•  ๋‹จ์–ด ์ž…๋ ฅ**", elem_id="input-box", placeholder="๋‹จ์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”", lines=1)
172
- submit_btn = gr.Button("์ œ์ถœ", elem_id="submit-btn")
 
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()