From b93244f2f8d6912186a580b2f49a312326699de8 Mon Sep 17 00:00:00 2001 From: "Guilherme D. Garcia" Date: Mon, 3 Apr 2023 15:17:29 -0400 Subject: [PATCH] updated ipa2tipa --- R/ipa2tipa.R | 10 +++++++--- man/ipa2tipa.Rd | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/R/ipa2tipa.R b/R/ipa2tipa.R index c9ea503..cf2d53e 100644 --- a/R/ipa2tipa.R +++ b/R/ipa2tipa.R @@ -8,12 +8,14 @@ #' parsimonous and avoid multiple uses of the \code{\\textipa} function. Therefore, #' this function isn't meant to be used to add new columns to your data frame or tibble. #' @param string The phonemically transcribed sequence from a function such as \code{ipa()} +#' @param pre Prefix for transcription. Defaults to "/ " +#' @param post Suffix for transcription. Defaults to " /" #' @return The tex code using \code{TIPA} #' @examples #' ipa2tipa(string = "bo.ni.to"); #' @export -ipa2tipa <- function(string) { +ipa2tipa <- function(string, pre = "/ ", post = " /") { ipa = string ipa <- stringr::str_replace_all(string, pattern = "$", replacement = "#") @@ -32,8 +34,8 @@ ipa2tipa <- function(string) { ipa <- ipa[ipa != ""] - pre = "\\textipa{ " - post = "}" + pre = stringr::str_c("\\textipa{ ", pre) + post = stringr::str_c(post, " }") ipa_dict <- list( "#" = " ", @@ -110,6 +112,8 @@ ipa2tipa <- function(string) { output[length(output) + 1] = ipa_dict[[ipa[i]]] } + output = output[-length(output)] + output = stringr::str_c(output, collapse = "") |> stringr::str_c(post, collapse = "") diff --git a/man/ipa2tipa.Rd b/man/ipa2tipa.Rd index c5e5197..b4ca5cc 100644 --- a/man/ipa2tipa.Rd +++ b/man/ipa2tipa.Rd @@ -4,10 +4,14 @@ \alias{ipa2tipa} \title{\code{TIPA} translator} \usage{ -ipa2tipa(string) +ipa2tipa(string, pre = "/ ", post = " /") } \arguments{ \item{string}{The phonemically transcribed sequence from a function such as \code{ipa()}} + +\item{pre}{Prefix for transcription. Defaults to "/ "} + +\item{post}{Suffix for transcription. Defaults to " /"} } \value{ The tex code using \code{TIPA}