Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -153,9 +153,9 @@ 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
|
157 |
next_source, next_target = get_current_text()
|
158 |
-
return next_source, next_target, "",
|
159 |
else:
|
160 |
return "已完成所有文本標記", "已完成所有文本標記", "", str(current_index), f"所有標記已完成並保存到 {score_file.name}!"
|
161 |
|
@@ -169,7 +169,7 @@ def update_file_selection(selected_file):
|
|
169 |
annotations_file = DATASET_DIR / f"{file_base_name}_annotations-{uuid4()}.json"
|
170 |
score_file = DATASET_DIR / f"{file_base_name}_score-{uuid4()}.json"
|
171 |
|
172 |
-
return get_current_text() + ("", "", f"已加載檔案:{selected_file}")
|
173 |
|
174 |
def update_index_selection(selected_index):
|
175 |
global current_index, data
|
@@ -215,7 +215,7 @@ with gr.Blocks() as demo:
|
|
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)
|
@@ -248,7 +248,8 @@ with gr.Blocks() as demo:
|
|
248 |
return gr.update(choices=subcategories, value=subcategories[0])
|
249 |
else:
|
250 |
return gr.update(choices=[], value=None)
|
251 |
-
|
|
|
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])
|
|
|
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, "", str(current_index), f"分數已保存到 {score_file.name},請繼續下一筆!"
|
159 |
else:
|
160 |
return "已完成所有文本標記", "已完成所有文本標記", "", str(current_index), f"所有標記已完成並保存到 {score_file.name}!"
|
161 |
|
|
|
169 |
annotations_file = DATASET_DIR / f"{file_base_name}_annotations-{uuid4()}.json"
|
170 |
score_file = DATASET_DIR / f"{file_base_name}_score-{uuid4()}.json"
|
171 |
|
172 |
+
return get_current_text() + ("", "0", str(current_index), f"已加載檔案:{selected_file}")
|
173 |
|
174 |
def update_index_selection(selected_index):
|
175 |
global current_index, data
|
|
|
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)
|
|
|
248 |
return gr.update(choices=subcategories, value=subcategories[0])
|
249 |
else:
|
250 |
return gr.update(choices=[], value=None)
|
251 |
+
|
252 |
+
file_selector.change(update_file_selection, inputs=[file_selector], outputs=[source, target, error_span, index_selector, current_index_display, status])
|
253 |
index_selector.change(update_index_selection, inputs=[index_selector], outputs=[source, target, current_index_display, status])
|
254 |
category.change(update_subcategories, inputs=[category], outputs=[subcategory])
|
255 |
save_current_button.click(save_current, inputs=[source, target, rater_selector, error_span, category, subcategory, severity, other], outputs=[error_span, status])
|