From 9aa9b4eaf8c4810e46b1244f9fe1af98029708c0 Mon Sep 17 00:00:00 2001 From: varunghat Date: Wed, 8 Jul 2026 17:16:28 +0200 Subject: [PATCH 1/4] fix: clicks no longer silently deleted when adjacent to a modifier --- scripts/aggregation-helper-functions.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/aggregation-helper-functions.R b/scripts/aggregation-helper-functions.R index 1b4605c..34bd92b 100644 --- a/scripts/aggregation-helper-functions.R +++ b/scripts/aggregation-helper-functions.R @@ -235,13 +235,13 @@ make_typestring <- function(strings, ...) { codepts <- get_codepoints(chars) codepts[codepts %in% get_codepoints(base_glyphs)] <- "B" codepts[codepts %in% get_codepoints(modifiers)] <- "M" - codepts[codepts %in% get_codepoints(clicks)] <- "M" + codepts[codepts %in% get_codepoints(clicks)] <- "K" codepts[codepts %in% get_codepoints(diacritics)] <- "D" codepts[codepts %in% get_codepoints(contour_glyphs)] <- "C" codepts[codepts %in% get_codepoints(tones)] <- "T" codepts[codepts %in% get_codepoints(null_phone)] <- "N" codepts[codepts %in% get_codepoints(disjunct)] <- "|" - missed <- !codepts %in% c("B", "M", "C", "D", "T", "N", "|") + missed <- !codepts %in% c("B", "M", "K", "C", "D", "T", "N", "|") if (any(missed)) { warning(paste("Unfamiliar glyph components.", "Phone:", string, "Codepoint:", codepts[missed]), From ee2a516dc8cead4abeb4f4619e4d9da52005265d Mon Sep 17 00:00:00 2001 From: varunghat Date: Mon, 10 Aug 2026 15:23:58 +0200 Subject: [PATCH 2/4] fix: click-diacritic reordering bug in order_ipa() --- scripts/aggregation-helper-functions.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/aggregation-helper-functions.R b/scripts/aggregation-helper-functions.R index 34bd92b..a22a01b 100644 --- a/scripts/aggregation-helper-functions.R +++ b/scripts/aggregation-helper-functions.R @@ -235,13 +235,13 @@ make_typestring <- function(strings, ...) { codepts <- get_codepoints(chars) codepts[codepts %in% get_codepoints(base_glyphs)] <- "B" codepts[codepts %in% get_codepoints(modifiers)] <- "M" - codepts[codepts %in% get_codepoints(clicks)] <- "K" + codepts[codepts %in% get_codepoints(clicks)] <- "M" codepts[codepts %in% get_codepoints(diacritics)] <- "D" codepts[codepts %in% get_codepoints(contour_glyphs)] <- "C" codepts[codepts %in% get_codepoints(tones)] <- "T" codepts[codepts %in% get_codepoints(null_phone)] <- "N" codepts[codepts %in% get_codepoints(disjunct)] <- "|" - missed <- !codepts %in% c("B", "M", "K", "C", "D", "T", "N", "|") + missed <- !codepts %in% c("B", "M", "C", "D", "T", "N", "|") if (any(missed)) { warning(paste("Unfamiliar glyph components.", "Phone:", string, "Codepoint:", codepts[missed]), @@ -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")) { From d7b7c730b1fdf92dc95d77b4f130b2974ca47700 Mon Sep 17 00:00:00 2001 From: varunghat Date: Mon, 10 Aug 2026 17:30:41 +0200 Subject: [PATCH 3/4] Added comments for click-modifier edge cases --- scripts/aggregation-helper-functions.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/aggregation-helper-functions.R b/scripts/aggregation-helper-functions.R index a22a01b..c7ec46f 100644 --- a/scripts/aggregation-helper-functions.R +++ b/scripts/aggregation-helper-functions.R @@ -235,6 +235,7 @@ make_typestring <- function(strings, ...) { codepts <- get_codepoints(chars) codepts[codepts %in% get_codepoints(base_glyphs)] <- "B" codepts[codepts %in% get_codepoints(modifiers)] <- "M" + # Clicks are typed as "M" so they factor into feature-vector assignment the same way modifiers do. codepts[codepts %in% get_codepoints(clicks)] <- "M" codepts[codepts %in% get_codepoints(diacritics)] <- "D" codepts[codepts %in% get_codepoints(contour_glyphs)] <- "C" @@ -299,6 +300,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 the modifier letter is a click, don't swap it with the diacritic 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) @@ -313,6 +315,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] + # Clicks are included here as they are typed as "M" above. string[span] <- c(clicks, modifiers)[c(clicks, modifiers) %in% mods] } } ## Put sequences of diacritics in canonical order From 72547492fd2ae22eb47c41552e158530b31b92ba Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Mon, 10 Aug 2026 11:08:02 -0500 Subject: [PATCH 4/4] Apply suggestion from @varunghat Co-authored-by: Varun G R <116162572+varunghat@users.noreply.github.com> --- scripts/aggregation-helper-functions.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/aggregation-helper-functions.R b/scripts/aggregation-helper-functions.R index c7ec46f..ddf767d 100644 --- a/scripts/aggregation-helper-functions.R +++ b/scripts/aggregation-helper-functions.R @@ -298,7 +298,14 @@ order_ipa <- function(strings, keep_stars=FALSE, keep_brackets=TRUE) { typestring <- paste(typstr, collapse="") } ## If a diacritic comes right after a modifier letter, swap their order - while (stri_detect_fixed(typestring, "MD")) { + if (stri_detect_fixed(typestring, "MD")) { + ixs <- stri_locate_all_fixed(typestring, "MD")[[1]] + for (row in seq_len(dim(ixs)[1])) { + ix <- ixs[row, 1] + if (string[ix] %in% clicks) next + # SWAP LOGIC REMAINS SAME + } } + ix <- stri_locate_first_fixed(typestring, "MD")[1] # If the modifier letter is a click, don't swap it with the diacritic if (string[ix] %in% clicks) break