Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -153,11 +153,11 @@ def save_and_next(source, target, score, rater_selector):
|
|
153 |
save_to_json(new_entry, score_file)
|
154 |
|
155 |
current_index += 1
|
156 |
-
if current_index < len(data):
|
157 |
next_source, next_target = get_current_text()
|
158 |
-
return next_source, next_target, "", "", f"分數已保存到 {score_file.name},請繼續下一筆!"
|
159 |
else:
|
160 |
-
return "已完成所有文本標記", "已完成所有文本標記", "", f"所有標記已完成並保存到 {score_file.name}!"
|
161 |
|
162 |
def update_file_selection(selected_file):
|
163 |
global data_path, data, current_index, annotations_file, score_file
|
@@ -213,17 +213,14 @@ with gr.Blocks() as demo:
|
|
213 |
with gr.Tab("標記工具"):
|
214 |
with gr.Row(equal_height=True):
|
215 |
with gr.Column(scale=1):
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
source = gr.Textbox(label="原始文本", interactive=False)
|
225 |
-
with gr.Column(scale=3):
|
226 |
-
target = gr.Textbox(label="翻譯文本", interactive=False)
|
227 |
|
228 |
with gr.Row(variant='panel', equal_height=True):
|
229 |
with gr.Column(scale=1):
|
@@ -255,7 +252,7 @@ with gr.Blocks() as demo:
|
|
255 |
index_selector.change(update_index_selection, inputs=[index_selector], outputs=[source, target, current_index_display, status])
|
256 |
category.change(update_subcategories, inputs=[category], outputs=[subcategory])
|
257 |
save_current_button.click(save_current, inputs=[source, target, rater_selector, error_span, category, subcategory, severity, other], outputs=[error_span, status])
|
258 |
-
save_next_button.click(save_and_next, inputs=[source, target, score, rater_selector], outputs=[source, target, error_span, status])
|
259 |
|
260 |
original, translated = get_current_text()
|
261 |
source.value = original
|
|
|
153 |
save_to_json(new_entry, score_file)
|
154 |
|
155 |
current_index += 1
|
156 |
+
if current_index + 1 < len(data):
|
157 |
next_source, next_target = get_current_text()
|
158 |
+
return next_source, next_target, "", "", str(current_index), f"分數已保存到 {score_file.name},請繼續下一筆!"
|
159 |
else:
|
160 |
+
return "已完成所有文本標記", "已完成所有文本標記", "", str(current_index), f"所有標記已完成並保存到 {score_file.name}!"
|
161 |
|
162 |
def update_file_selection(selected_file):
|
163 |
global data_path, data, current_index, annotations_file, score_file
|
|
|
213 |
with gr.Tab("標記工具"):
|
214 |
with gr.Row(equal_height=True):
|
215 |
with gr.Column(scale=1):
|
216 |
+
rater_selector = gr.Dropdown(label="標註人員", choices=rater, value="rater1")
|
217 |
+
file_selector = gr.Dropdown(label="選擇檔案", choices=csv_files, value="test.csv")
|
218 |
+
index_selector = gr.Dropdown(label="選擇索引", choices=get_all_ids(), value=0)
|
219 |
+
current_index_display = gr.Textbox(label="當前索引", value=str(current_index), interactive=False)
|
220 |
+
with gr.Column(scale=6):
|
221 |
+
source = gr.Textbox(label="原始文本", lines=10, interactive=False)
|
222 |
+
with gr.Column(scale=6):
|
223 |
+
target = gr.Textbox(label="翻譯文本", lines=10, interactive=False)
|
|
|
|
|
|
|
224 |
|
225 |
with gr.Row(variant='panel', equal_height=True):
|
226 |
with gr.Column(scale=1):
|
|
|
252 |
index_selector.change(update_index_selection, inputs=[index_selector], outputs=[source, target, current_index_display, status])
|
253 |
category.change(update_subcategories, inputs=[category], outputs=[subcategory])
|
254 |
save_current_button.click(save_current, inputs=[source, target, rater_selector, error_span, category, subcategory, severity, other], outputs=[error_span, status])
|
255 |
+
save_next_button.click(save_and_next, inputs=[source, target, score, rater_selector], outputs=[source, target, error_span, current_index_display, status])
|
256 |
|
257 |
original, translated = get_current_text()
|
258 |
source.value = original
|