[Bug]: Translator cannot deal with sentences starting with the same string.
Closed this issue · 1 comments
rprops commented
Guidelines
- I agree to follow this project's Contributing Guidelines.
Project Version
No response
Platform and OS Version
Windows 10
Existing Issues
No response
What happened?
I have a translation file in which many sentences start with the same words. This causes an error in which duplicate rownames are generated (unclear where) and the translation stops (see below). Presumably this is because the first word is stored as rowname of the DF.
Most likely culprit:
column_to_row <- function(data, colname) {
stopifnot(colname %in% colnames(data))
key_index <- which(colname == colnames( (data) ))
ndata <- data[-key_index]
rownames(ndata) <- data[, key_index]
ndata
}
Steps to reproduce
- Make translation CSV file with different rows starting with the exact same character.
- Run serverside translation workflow:
translator <- Translator$new(translation_csvs_path = "./inst/extdata/")
- Following error is generated:
Error in `.rowNamesDF<-`(x, value = value) :
duplicate 'row.names' are not allowed
- When you remove the sentences starting with the same strings, the error is resolved.
Expected behavior
Text should be translated without triggering the error.
Attachments
No response
Screenshots or Videos
No response
Additional Information
No response
rprops commented
Problem was caused by commas being present in strings in CSV, thereby artificially replicating certain parts of sentences.