Skip to content

Commit

Permalink
updated ipa2tipa
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme D. Garcia committed Apr 3, 2023
1 parent 71685c7 commit b93244f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 7 additions & 3 deletions R/ipa2tipa.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "#")
Expand All @@ -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(
"#" = " ",
Expand Down Expand Up @@ -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 = "")

Expand Down
6 changes: 5 additions & 1 deletion man/ipa2tipa.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b93244f

Please sign in to comment.