Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -191,36 +191,39 @@ def CogMapAnalysis(text):
|
|
| 191 |
|
| 192 |
# Create the GUI using the 'gr' library
|
| 193 |
with gr.Blocks() as demo:
|
| 194 |
-
gr.
|
|
|
|
| 195 |
|
| 196 |
with gr.Row():
|
| 197 |
with gr.Column():
|
| 198 |
-
inputs = gr.Textbox(label="Input
|
| 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 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
inputs=inputs,
|
| 218 |
-
outputs=[output, cogmap_plot]
|
| 219 |
-
)
|
| 220 |
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
-
|
|
|
|
| 224 |
|
| 225 |
if __name__ == "__main__":
|
| 226 |
demo.launch(show_api=False, share=True)
|
|
|
|
| 191 |
|
| 192 |
# Create the GUI using the 'gr' library
|
| 193 |
with gr.Blocks() as demo:
|
| 194 |
+
with gr.Row():
|
| 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 |
with gr.Column():
|
| 199 |
+
inputs = gr.Textbox(label="Input", lines=2, placeholder="Enter your text here...")
|
|
|
|
| 200 |
submit_button = gr.Button("Submit")
|
| 201 |
with gr.Column():
|
| 202 |
+
examples = [
|
| 203 |
+
"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.",
|
| 204 |
+
"The introduction of new anti-discrimination laws has been driven by an increasing awareness of social injustices and grassroots movements.",
|
| 205 |
+
"The weak law enforcement in this country is due to its citizens's ignorance.",
|
| 206 |
+
"CogMApp is a tool that lets you create cognitive maps from text."
|
| 207 |
+
]
|
| 208 |
+
example_dropdown = gr.Dropdown(label="Examples", choices=examples, type="index")
|
| 209 |
+
load_example_button = gr.Button("Load Example")
|
| 210 |
+
|
| 211 |
+
with gr.Row():
|
| 212 |
+
output = gr.Textbox(label="CogMApp", lines=1, placeholder=" ")
|
| 213 |
+
cogmap_plot = gr.Plot(label="Visualization")
|
| 214 |
+
|
| 215 |
+
with gr.Row():
|
| 216 |
+
gr.Markdown("⚠️ Feel free to flag me if you find any errors. :)")
|
|
|
|
|
|
|
|
|
|
| 217 |
|
| 218 |
+
with gr.Row():
|
| 219 |
+
gr.Markdown('<p style="text-align: center; ">Demo made with ❤ by P.K. Ningrum (2024) | Contact: https://ningrumdaud.github.io/ </p>')
|
| 220 |
+
|
| 221 |
+
# Function to handle loading examples
|
| 222 |
+
def load_example(example_index):
|
| 223 |
+
inputs.value = examples[example_index]
|
| 224 |
|
| 225 |
+
example_dropdown.change(load_example, inputs=[example_dropdown], outputs=[inputs])
|
| 226 |
+
submit_button.click(CogMapAnalysis, inputs=[inputs], outputs=[output, cogmap_plot])
|
| 227 |
|
| 228 |
if __name__ == "__main__":
|
| 229 |
demo.launch(show_api=False, share=True)
|