ningrumdaud commited on
Commit
5aa0920
·
verified ·
1 Parent(s): 662682d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -17
app.py CHANGED
@@ -191,27 +191,37 @@ def CogMapAnalysis(text):
191
 
192
  # Create the GUI using the 'gr' library
193
  with gr.Blocks() as demo:
194
- with gr.Column():
195
- gr.Markdown('<div style="text-align: center;"><h1><strong>CogMApp</strong></h1></div> <div style="text-align: center;"><h3>Generate cognitive maps from text with one click!</h3></div>')
196
 
197
  with gr.Row():
198
- inputs = gr.Textbox(label="Input", lines=2, placeholder="Enter your text here...")
199
- examples = [
200
- "Public support for anti-discrimination laws and the movement to support immigrants grew due to the impact of getting widespread education on social justice issues.",
201
- "The introduction of new anti-discrimination laws has been driven by an increasing awareness of social injustices and grassroots movements.",
202
- "The weak enforcement in this country is due to its citizens's ignorance.",
203
- "CogMApp is a tool that lets you create cognitive maps from text."
204
- ]
205
-
206
- output = gr.Textbox(label="CogMap", lines=1, placeholder=" ")
207
- cogmap_plot = gr.Plot(label="Visualization")
208
- interface = gr.Interface(fn=CogMapAnalysis, examples=examples, inputs=inputs, outputs=[output, cogmap_plot])
 
 
 
209
 
210
- with gr.Row():
211
- gr.Markdown("⚠️ Feel free to flag me if you find any errors. :)")
 
 
 
 
 
 
212
 
213
- with gr.Column():
214
- gr.Markdown('<p style="text-align: center; ">Demo made with ❤ by P.K. Ningrum (2024) | Contact: https://ningrumdaud.github.io/ </p>')
 
215
 
216
  if __name__ == "__main__":
217
  demo.launch(show_api=False, share=True)
 
 
191
 
192
  # Create the GUI using the 'gr' library
193
  with gr.Blocks() as demo:
194
+ gr.Markdown('<div style="text-align: center;"><h1><strong>CogMApp</strong></h1></div> <div style="text-align: center;"><h3>Generate cognitive maps from text with one click!</h3></div>')
 
195
 
196
  with gr.Row():
197
+ with gr.Column():
198
+ inputs = gr.Textbox(label="Input Text", lines=4, placeholder="Enter your text here...")
199
+ output = gr.Textbox(label="CogMap Output", lines=4, placeholder="Processed output appears here...", interactive=False)
200
+ submit_button = gr.Button("Submit")
201
+ with gr.Column():
202
+ cogmap_plot = gr.Plot(label="Visualization")
203
+ gr.Markdown("⚠️ Feel free to flag me if you find any errors. 🙂")
204
+
205
+ examples = [
206
+ "Public support for anti-discrimination laws and the movement to support immigrants grew due to the impact of widespread education on social justice issues.",
207
+ "The introduction of new anti-discrimination laws has been driven by an increasing awareness of social injustices and grassroots movements.",
208
+ "The weak enforcement in this country is due to its citizens' ignorance.",
209
+ "CogMApp is a tool that lets you create cognitive maps from text."
210
+ ]
211
 
212
+ def update_output(input_text):
213
+ return CogMapAnalysis(input_text)
214
+
215
+ submit_button.click(
216
+ fn=update_output,
217
+ inputs=inputs,
218
+ outputs=[output, cogmap_plot]
219
+ )
220
 
221
+ inputs.add_examples(examples, fn=CogMapAnalysis)
222
+
223
+ gr.Markdown('<p style="text-align: center; ">Demo made with ❤ by P.K. Ningrum (2024) | Contact: <a href="https://ningrumdaud.github.io/">https://ningrumdaud.github.io/</a></p>')
224
 
225
  if __name__ == "__main__":
226
  demo.launch(show_api=False, share=True)
227
+