파파고 번역 시 내용을 분리할 DELIMITER 변경
This commit is contained in:
@@ -36,7 +36,7 @@ class PapagoTranslationService(
|
||||
val translatedTexts = mutableListOf<String>()
|
||||
|
||||
chunks.forEach { chunk ->
|
||||
val textsInChunkCount = chunk.split(S3P_DELIMITER).size
|
||||
val textsInChunkCount = chunk.split(DELIMITER).size
|
||||
|
||||
try {
|
||||
val body = mapOf(
|
||||
@@ -61,7 +61,7 @@ class PapagoTranslationService(
|
||||
if (translated.isNullOrBlank()) {
|
||||
repeat(textsInChunkCount) { translatedTexts.add("") }
|
||||
} else {
|
||||
translated.split(S3P_DELIMITER).forEach { translatedTexts.add(it) }
|
||||
translated.split(DELIMITER).forEach { translatedTexts.add(it) }
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
repeat(textsInChunkCount) { translatedTexts.add("") }
|
||||
@@ -91,7 +91,7 @@ class PapagoTranslationService(
|
||||
var endIndex = texts.size
|
||||
while (endIndex > startIndex) {
|
||||
val candidate = texts.subList(startIndex, endIndex)
|
||||
val joined = candidate.joinToString(S3P_DELIMITER)
|
||||
val joined = candidate.joinToString(DELIMITER)
|
||||
if (joined.length <= MAX_TEXT_LENGTH || endIndex - startIndex == 1) {
|
||||
chunks.add(joined)
|
||||
startIndex = endIndex
|
||||
@@ -121,7 +121,7 @@ class PapagoTranslationService(
|
||||
"it"
|
||||
)
|
||||
|
||||
private const val S3P_DELIMITER = "__S3P__"
|
||||
private const val DELIMITER = "\u001F\u001E\u001D\u001C\u001F\u001E\u001D\u001C"
|
||||
private const val MAX_TEXT_LENGTH = 3000
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user