Spaces:
Sleeping
Sleeping
add chunk size function
Browse files
app.py
CHANGED
@@ -172,7 +172,7 @@ def basic_translate(source_sentence, src_language, tgt_language):
|
|
172 |
translations.append(translation)
|
173 |
return translations
|
174 |
|
175 |
-
def summary_translate(src_text, temp_tgt_text, tgt_language):
|
176 |
system_prompts = ["You are a helpful rephraser. You only output the rephrased result."]
|
177 |
translations = []
|
178 |
for prompt_style in system_prompts:
|
@@ -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(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:
|
|
|
172 |
translations.append(translation)
|
173 |
return translations
|
174 |
|
175 |
+
def summary_translate(src_text, temp_tgt_text, tgt_language, session_id):
|
176 |
system_prompts = ["You are a helpful rephraser. You only output the rephrased result."]
|
177 |
translations = []
|
178 |
for prompt_style in system_prompts:
|
|
|
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, session_id)
|
322 |
orig_output = f"{orig}\n\nScore: {best_score:.2f}"
|
323 |
+
plan2align_trans, best_score = summary_translate(text, p2a_combined_translation, target_language, session_id)
|
324 |
plan2align_output = f"{plan2align_trans}\n\nScore: {best_score:.2f}"
|
325 |
+
best_candidate, best_score = summary_translate(text, bfn_combined_translation, target_language, session_id)
|
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, session_id)
|
328 |
mpc_output = f"{mpc_candidate}\n\nScore: {mpc_score:.2f}"
|
329 |
|
330 |
# if "Original" in translation_methods:
|