Spaces:
Paused
Paused
add chunk size function
Browse files
app.py
CHANGED
|
@@ -182,7 +182,7 @@ def summary_translate(src_text, temp_tgt_text, tgt_language):
|
|
| 182 |
translation = generate_translation(prompt_style, prompt)
|
| 183 |
translations.append(translation)
|
| 184 |
|
| 185 |
-
best, score = evaluate_candidates(src_text, translations,
|
| 186 |
if cand_list:
|
| 187 |
return best, score
|
| 188 |
return "", 0
|
|
@@ -318,13 +318,13 @@ def process_text(text, src_language, target_language, max_iterations_value, thre
|
|
| 318 |
bfn_combined_translation = ' '.join(bfn_translated_chunks)
|
| 319 |
mpc_combined_translation = ' '.join(mpc_translated_chunks)
|
| 320 |
|
| 321 |
-
orig, best_score = summary_translate(org_combined_translation, target_language)
|
| 322 |
orig_output = f"{orig}\n\nScore: {best_score:.2f}"
|
| 323 |
-
plan2align_trans, best_score = summary_translate(p2a_combined_translation, target_language)
|
| 324 |
plan2align_output = f"{plan2align_trans}\n\nScore: {best_score:.2f}"
|
| 325 |
-
best_candidate, best_score = summary_translate(bfn_combined_translation, target_language)
|
| 326 |
best_of_n_output = f"{best_candidate}\n\nScore: {best_score:.2f}"
|
| 327 |
-
mpc_candidate, best_score = summary_translate(mpc_combined_translation, target_language)
|
| 328 |
mpc_output = f"{mpc_candidate}\n\nScore: {mpc_score:.2f}"
|
| 329 |
|
| 330 |
# if "Original" in translation_methods:
|
|
@@ -371,7 +371,7 @@ with gr.Blocks(title="Test-Time Machine Translation with Plan2Align") as demo:
|
|
| 371 |
task_language_input = gr.Dropdown(
|
| 372 |
choices=target_languages,
|
| 373 |
value="English",
|
| 374 |
-
label="
|
| 375 |
)
|
| 376 |
max_iterations_input = gr.Number(label="Max Iterations", value=6)
|
| 377 |
threshold_input = gr.Number(label="Threshold", value=0.7)
|
|
@@ -382,7 +382,7 @@ with gr.Blocks(title="Test-Time Machine Translation with Plan2Align") as demo:
|
|
| 382 |
label="Translation Methods"
|
| 383 |
)
|
| 384 |
chunk_size_input = gr.Number( # ✅ add chunk function
|
| 385 |
-
label="Chunk Size (
|
| 386 |
value=-1
|
| 387 |
)
|
| 388 |
translate_button = gr.Button("Translate")
|
|
|
|
| 182 |
translation = generate_translation(prompt_style, prompt)
|
| 183 |
translations.append(translation)
|
| 184 |
|
| 185 |
+
best, score = evaluate_candidates(src_text, translations, tgt_language, session_id)
|
| 186 |
if cand_list:
|
| 187 |
return best, score
|
| 188 |
return "", 0
|
|
|
|
| 318 |
bfn_combined_translation = ' '.join(bfn_translated_chunks)
|
| 319 |
mpc_combined_translation = ' '.join(mpc_translated_chunks)
|
| 320 |
|
| 321 |
+
orig, best_score = summary_translate(text, org_combined_translation, target_language)
|
| 322 |
orig_output = f"{orig}\n\nScore: {best_score:.2f}"
|
| 323 |
+
plan2align_trans, best_score = summary_translate(text, p2a_combined_translation, target_language)
|
| 324 |
plan2align_output = f"{plan2align_trans}\n\nScore: {best_score:.2f}"
|
| 325 |
+
best_candidate, best_score = summary_translate(text, bfn_combined_translation, target_language)
|
| 326 |
best_of_n_output = f"{best_candidate}\n\nScore: {best_score:.2f}"
|
| 327 |
+
mpc_candidate, best_score = summary_translate(text, mpc_combined_translation, target_language)
|
| 328 |
mpc_output = f"{mpc_candidate}\n\nScore: {mpc_score:.2f}"
|
| 329 |
|
| 330 |
# if "Original" in translation_methods:
|
|
|
|
| 371 |
task_language_input = gr.Dropdown(
|
| 372 |
choices=target_languages,
|
| 373 |
value="English",
|
| 374 |
+
label="Target Language"
|
| 375 |
)
|
| 376 |
max_iterations_input = gr.Number(label="Max Iterations", value=6)
|
| 377 |
threshold_input = gr.Number(label="Threshold", value=0.7)
|
|
|
|
| 382 |
label="Translation Methods"
|
| 383 |
)
|
| 384 |
chunk_size_input = gr.Number( # ✅ add chunk function
|
| 385 |
+
label="Chunk Size (-1 for all)",
|
| 386 |
value=-1
|
| 387 |
)
|
| 388 |
translate_button = gr.Button("Translate")
|