anna-tch commited on
Commit
1bb5f79
·
1 Parent(s): 11cf5bf

Add application file

Browse files
Files changed (1) hide show
  1. app.py +37 -23
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
- gr.Button("Annotated").click(
118
- lambda s: switch_view("annotated", s),
119
- inputs=[state],
120
- outputs=[state]
121
- )
122
- gr.Button("Unannotated").click(
123
- lambda s: switch_view("unannotated", s),
124
- inputs=[state],
125
- outputs=[state]
126
- )
127
-
128
- with gr.Row():
129
- counter = gr.Markdown()
130
-
131
- with gr.Row():
132
- with gr.Column():
133
- text_display = gr.Textbox(label="Generated Text", interactive=False)
134
  with gr.Row():
135
- grammar = gr.Radio(choices=[1, 2, 3, 4, 5], label="Grammar Score")
136
- coherence = gr.Radio(choices=[1, 2, 3, 4, 5], label="Coherence Score")
 
 
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