번역한 텍스트가 \n문자가 사라지는 문제 발생
def translate_with_linebreaks(text):
"""
Translate text with line breaks
text: str
return: str
"""
lines = [line.strip() for line in text.split('\n') if line.strip()]
translated = translator(lines, batch_size=8)
return '\n'.join([t['translation_text'] for t in translated])
문자열을 \n 기준으로 나눠서 개별 번역후 다시 합쳐서 반환하여 해결
'개발일지 > BrewWing' 카테고리의 다른 글
| Trouble Shooting: "status.code": 4 (0) | 2025.04.14 |
|---|---|
| TroubleShooting: Traceback Error (0) | 2025.02.04 |
| 번역 기능 추가 (1) | 2025.02.04 |
| TroubleShooting: Llama 답변 구조 문제 (0) | 2025.01.29 |
| TroubleShooting: 답변 줄 정리 (0) | 2025.01.29 |