-
Notifications
You must be signed in to change notification settings - Fork 2
/
create_transliteration_table.R
31 lines (29 loc) · 1.1 KB
/
create_transliteration_table.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#' Create a Transliteration Table
#'
#' This function generates a transliteration table by transliterating a list of words into multiple languages.
#'
#' @param words A character vector containing the words to be transliterated.
#' @param languages A character vector specifying the target languages for transliteration.
#' @return A data frame representing the transliteration table with original words and transliterations in each language.
#'
#' @importFrom rlang :=
#' @export
#'
#' @examples
#' words <- c("Hello world", "Goodbye", "Thank you", "Please")
#' languages <- c("ar", "he", "el", "ru", "fa")
#' transliterations <- create_transliteration_table(words, languages)
#' print(transliterations)
create_transliteration_table <- function(words, languages) {
original_word <- NULL
transliterations <- data.frame(original_word = words)
for (language in languages) {
column_name <- language
transliterations <- transliterations %>%
dplyr::mutate("{column_name}" := purrr::map_chr(
original_word,
~ google_transliterate(., language, num=1)
))
}
return(transliterations)
}