SCBconsulting commited on
Commit
1e80870
·
verified ·
1 Parent(s): f42b944

Update utils/translator.py

Browse files
Files changed (1) hide show
  1. utils/translator.py +12 -0
utils/translator.py CHANGED
@@ -70,6 +70,18 @@ def translate_to_english(text: str) -> str:
70
  chunks = chunk_text(clean_text(text))
71
  return translate_chunks(chunks, tokenizer_pt_en, model_pt_en)
72
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  # ========== Bilingual View ==========
74
 
75
  def bilingual_clauses(english_text: str) -> str:
 
70
  chunks = chunk_text(clean_text(text))
71
  return translate_chunks(chunks, tokenizer_pt_en, model_pt_en)
72
 
73
+ def translate_text(text: str, direction: str = "en-pt") -> str:
74
+ """
75
+ 🌐 Wrapper para tradução direta via Gradio.
76
+ direction = "en-pt" ou "pt-en"
77
+ """
78
+ if direction == "en-pt":
79
+ return translate_to_portuguese(text)
80
+ elif direction == "pt-en":
81
+ return translate_to_english(text)
82
+ else:
83
+ return "Unsupported translation direction."
84
+
85
  # ========== Bilingual View ==========
86
 
87
  def bilingual_clauses(english_text: str) -> str: