Spaces:
Runtime error
Runtime error
Add application file
Browse files
app.py
CHANGED
|
@@ -107,41 +107,54 @@ def submit(grammar, coherence, state):
|
|
| 107 |
update_dataset(state)
|
| 108 |
|
| 109 |
return navigate("next", state)
|
| 110 |
-
|
| 111 |
with gr.Blocks() as app:
|
| 112 |
state = gr.State(load_data())
|
| 113 |
|
| 114 |
gr.Markdown("## Text Annotation Tool")
|
| 115 |
|
| 116 |
with gr.Row():
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
with gr.Row():
|
| 132 |
-
with gr.Column():
|
| 133 |
-
text_display = gr.Textbox(label="Generated Text", interactive=False)
|
| 134 |
with gr.Row():
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
| 137 |
with gr.Row():
|
| 138 |
-
prev_btn = gr.Button("Previous")
|
| 139 |
-
next_btn = gr.Button("Next")
|
| 140 |
-
submit_btn = gr.Button("Submit")
|
| 141 |
|
|
|
|
| 142 |
navigation_inputs = [state]
|
| 143 |
navigation_outputs = [text_display, grammar, coherence, counter, state]
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
prev_btn.click(
|
| 146 |
lambda s: navigate("prev", s),
|
| 147 |
inputs=navigation_inputs,
|
|
@@ -165,6 +178,7 @@ with gr.Blocks() as app:
|
|
| 165 |
outputs=navigation_outputs
|
| 166 |
)
|
| 167 |
|
|
|
|
| 168 |
if __name__ == "__main__":
|
| 169 |
app.launch(share=True)
|
| 170 |
|
|
|
|
| 107 |
update_dataset(state)
|
| 108 |
|
| 109 |
return navigate("next", state)
|
|
|
|
| 110 |
with gr.Blocks() as app:
|
| 111 |
state = gr.State(load_data())
|
| 112 |
|
| 113 |
gr.Markdown("## Text Annotation Tool")
|
| 114 |
|
| 115 |
with gr.Row():
|
| 116 |
+
# Sidebar Column
|
| 117 |
+
with gr.Column(scale=1, min_width=200):
|
| 118 |
+
gr.Markdown("### Navigation")
|
| 119 |
+
with gr.Column(style={"background": "#f0f0f0", "padding": "20px", "border-radius": "10px"}):
|
| 120 |
+
annotated_btn = gr.Button("Annotated", variant="primary")
|
| 121 |
+
unannotated_btn = gr.Button("Unannotated", variant="primary")
|
| 122 |
+
gr.Markdown("---")
|
| 123 |
+
counter = gr.Markdown()
|
| 124 |
+
|
| 125 |
+
# Main Content Column
|
| 126 |
+
with gr.Column(scale=4):
|
| 127 |
+
with gr.Row():
|
| 128 |
+
text_display = gr.Textbox(label="Generated Text", interactive=False)
|
| 129 |
+
|
|
|
|
|
|
|
|
|
|
| 130 |
with gr.Row():
|
| 131 |
+
with gr.Column(scale=1):
|
| 132 |
+
grammar = gr.Radio(choices=[1, 2, 3, 4, 5], label="Grammar Score")
|
| 133 |
+
coherence = gr.Radio(choices=[1, 2, 3, 4, 5], label="Coherence Score")
|
| 134 |
+
|
| 135 |
with gr.Row():
|
| 136 |
+
prev_btn = gr.Button("Previous", variant="secondary")
|
| 137 |
+
next_btn = gr.Button("Next", variant="secondary")
|
| 138 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
| 139 |
|
| 140 |
+
# Event handlers
|
| 141 |
navigation_inputs = [state]
|
| 142 |
navigation_outputs = [text_display, grammar, coherence, counter, state]
|
| 143 |
|
| 144 |
+
# Connect sidebar buttons
|
| 145 |
+
annotated_btn.click(
|
| 146 |
+
lambda s: switch_view("annotated", s),
|
| 147 |
+
inputs=[state],
|
| 148 |
+
outputs=navigation_outputs
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
+
unannotated_btn.click(
|
| 152 |
+
lambda s: switch_view("unannotated", s),
|
| 153 |
+
inputs=[state],
|
| 154 |
+
outputs=navigation_outputs
|
| 155 |
+
)
|
| 156 |
+
|
| 157 |
+
# Keep existing event handlers for other buttons
|
| 158 |
prev_btn.click(
|
| 159 |
lambda s: navigate("prev", s),
|
| 160 |
inputs=navigation_inputs,
|
|
|
|
| 178 |
outputs=navigation_outputs
|
| 179 |
)
|
| 180 |
|
| 181 |
+
|
| 182 |
if __name__ == "__main__":
|
| 183 |
app.launch(share=True)
|
| 184 |
|