diff --git a/scripts/aggregation-helper-functions.R b/scripts/aggregation-helper-functions.R index 1b4605c..a22a01b 100644 --- a/scripts/aggregation-helper-functions.R +++ b/scripts/aggregation-helper-functions.R @@ -299,6 +299,7 @@ order_ipa <- function(strings, keep_stars=FALSE, keep_brackets=TRUE) { ## If a diacritic comes right after a modifier letter, swap their order while (stri_detect_fixed(typestring, "MD")) { ix <- stri_locate_first_fixed(typestring, "MD")[1] + if (string[ix] %in% clicks) break if (ix == 1) neworder <- c(2, 1, 3:lenstr) else if (ix == lenstr-1) neworder <- c(1:(ix-1), ix+1, ix) else neworder <- c(1:(ix-1), ix+1, ix, (ix+2):lenstr) @@ -312,7 +313,7 @@ order_ipa <- function(strings, keep_stars=FALSE, keep_brackets=TRUE) { for (row in seq_len(dim(ixs)[1])) { span <- ixs[row,1]:ixs[row,2] mods <- string[span] - string[span] <- modifiers[modifiers %in% mods] + string[span] <- c(clicks, modifiers)[c(clicks, modifiers) %in% mods] } } ## Put sequences of diacritics in canonical order if (stri_detect_fixed(typestring, "DD")) {