Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -77,12 +77,9 @@ score_file = DATASET_DIR / f"test_score-{uuid4()}.json"
|
|
77 |
|
78 |
def get_current_text():
|
79 |
global current_index, data
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
return source, target
|
84 |
-
else:
|
85 |
-
return "已完成所有文本標記", "已完成所有文本標記"
|
86 |
|
87 |
def save_to_json(entry: dict, json_file: Path):
|
88 |
"""
|
@@ -140,6 +137,9 @@ def save_and_next(source, target, score, rater_selector):
|
|
140 |
doc = data.loc[current_index, "doc"]
|
141 |
id = int(data.loc[current_index, "id"])
|
142 |
reference = data.loc[current_index, "reference"]
|
|
|
|
|
|
|
143 |
|
144 |
new_entry = {
|
145 |
"system": system,
|
@@ -155,7 +155,8 @@ def save_and_next(source, target, score, rater_selector):
|
|
155 |
save_to_json(new_entry, score_file)
|
156 |
|
157 |
current_index += 1
|
158 |
-
|
|
|
159 |
return "已完成所有文本標記", "已完成所有文本標記", "", "", f"所有標記已完成並保存到 {score_file.name}!"
|
160 |
|
161 |
next_source, next_target = get_current_text()
|
|
|
77 |
|
78 |
def get_current_text():
|
79 |
global current_index, data
|
80 |
+
source = data.loc[current_index, "source"]
|
81 |
+
target = data.loc[current_index, "target"]
|
82 |
+
return source, target
|
|
|
|
|
|
|
83 |
|
84 |
def save_to_json(entry: dict, json_file: Path):
|
85 |
"""
|
|
|
137 |
doc = data.loc[current_index, "doc"]
|
138 |
id = int(data.loc[current_index, "id"])
|
139 |
reference = data.loc[current_index, "reference"]
|
140 |
+
|
141 |
+
id_list = [str(id) for id in sorted(data["id"].unique())]
|
142 |
+
max_id = int(id_list[-1]) # 取得最大的 ID
|
143 |
|
144 |
new_entry = {
|
145 |
"system": system,
|
|
|
155 |
save_to_json(new_entry, score_file)
|
156 |
|
157 |
current_index += 1
|
158 |
+
count = data.index[data["id"] == current_index].tolist()[0]
|
159 |
+
if current_index > max_id:
|
160 |
return "已完成所有文本標記", "已完成所有文本標記", "", "", f"所有標記已完成並保存到 {score_file.name}!"
|
161 |
|
162 |
next_source, next_target = get_current_text()
|