Spaces:
Sleeping
Sleeping
Commit
·
90c12a2
1
Parent(s):
c306eb7
Upd syntax
Browse files- vi/processing.py +3 -3
vi/processing.py
CHANGED
|
@@ -233,12 +233,12 @@ def translate_rag_row(row: Dict[str, Any], translator, text_fields: List[str] =
|
|
| 233 |
logger.debug(f" Are they the same? {original == translated}")
|
| 234 |
|
| 235 |
# Validate and sanitize translated field
|
| 236 |
-
|
| 237 |
translated_row[field] = _vi_sanitize_text(translated)
|
| 238 |
logger.debug(f"✅ Successfully translated RAG field '{field}'")
|
| 239 |
# Add success statistics if stats available
|
| 240 |
if hasattr(translator, '_stats'):
|
| 241 |
-
|
| 242 |
else:
|
| 243 |
logger.warning(f"❌ Invalid Vietnamese translation for RAG field {field}, keeping original")
|
| 244 |
logger.warning(f" Original: '{original[:50]}...'")
|
|
@@ -250,7 +250,7 @@ def translate_rag_row(row: Dict[str, Any], translator, text_fields: List[str] =
|
|
| 250 |
except Exception as e:
|
| 251 |
logger.error(f"Failed to translate RAG field '{field}': {e}")
|
| 252 |
translated_row[field] = row[field]
|
| 253 |
-
|
| 254 |
# Keep original if field doesn't exist or is empty
|
| 255 |
translated_row[field] = row.get(field, "")
|
| 256 |
|
|
|
|
| 233 |
logger.debug(f" Are they the same? {original == translated}")
|
| 234 |
|
| 235 |
# Validate and sanitize translated field
|
| 236 |
+
if _validate_vi_translation(original, translated):
|
| 237 |
translated_row[field] = _vi_sanitize_text(translated)
|
| 238 |
logger.debug(f"✅ Successfully translated RAG field '{field}'")
|
| 239 |
# Add success statistics if stats available
|
| 240 |
if hasattr(translator, '_stats'):
|
| 241 |
+
add_translation_stats(translator._stats, f"rag_{field}", True)
|
| 242 |
else:
|
| 243 |
logger.warning(f"❌ Invalid Vietnamese translation for RAG field {field}, keeping original")
|
| 244 |
logger.warning(f" Original: '{original[:50]}...'")
|
|
|
|
| 250 |
except Exception as e:
|
| 251 |
logger.error(f"Failed to translate RAG field '{field}': {e}")
|
| 252 |
translated_row[field] = row[field]
|
| 253 |
+
else:
|
| 254 |
# Keep original if field doesn't exist or is empty
|
| 255 |
translated_row[field] = row.get(field, "")
|
| 256 |
|