From 4db54f5d475a159e2bf55ce93d0b3eb4bbcc21e4 Mon Sep 17 00:00:00 2001 From: con3code Date: Tue, 20 Oct 2026 19:33:13 +0900 Subject: [PATCH] Mojikumi: the reduction tier follows the character classes Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013phQ3ekq6uGBEWD6FjFYG2 --- crates/doc/src/mojikumi.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/crates/doc/src/mojikumi.rs b/crates/doc/src/mojikumi.rs index 6bef0e60c..3b2a917b5 100644 --- a/crates/doc/src/mojikumi.rs +++ b/crates/doc/src/mojikumi.rs @@ -128,17 +128,20 @@ impl<'a> Rules<'a> { } let punctuation = trailing(left).max(leading(right)); if punctuation > 0.0 { - // The Japanese sets take a line in at the quarter ems of middle dots first, then at the - // half ems of brackets and commas, and don't reduce the space after a full stop - // (JLREQ 3.8.3). The Chinese sets reduce all punctuation blanks together. + // The Japanese sets take a line in at the quarter ems of middle dots (・:;) first, then + // at the half ems of brackets and commas, and don't reduce the space after a full stop + // (JLREQ 3.8.3). !? share the first tier: JLREQ sets them solid (Table 1) and + // gives the quarter em only as an alternative (3.1.6), so reducing it first returns + // to that default. The tier follows the character classes, not the blank's size. The + // Chinese sets reduce all punctuation blanks together. let japanese = self.base != Base::Chinese; - let quarter = punctuation < 0.5; + let bracket_or_comma = matches!(left, 2 | 6 | 21 | 28..=31) || matches!(right, 1 | 26 | 27); let full_stop = matches!(left, 6 | 31); return Aki { min: if japanese && full_stop { punctuation } else { 0.0 }, desired: punctuation, max: punctuation, - priority: if japanese && !quarter { 2 } else { 1 }, + priority: if japanese && bracket_or_comma { 2 } else { 1 }, discrete: false, }; } @@ -298,6 +301,12 @@ mod tests { assert!(dot.priority == after_dot.priority && dot.priority < comma.priority, "{set}"); assert!(comma.priority == close.priority && close.priority == open.priority && open.priority < wa_ou.priority, "{set}"); assert_eq!((dot.min, comma.min, close.min, open.min), (0.0, 0.0, 0.0, 0.0), "{set}"); + // The tier follows the class: :;!? share the middle dots' tier, and a bracket's half + // em beside a middle dot stays with the brackets. + for (a, b) in [('漢', ':'), (';', '漢'), ('漢', '!'), ('?', '漢')] { + assert_eq!(aki(a, b).priority, dot.priority, "{set}: {a}{b}"); + } + assert_eq!(aki('・', '「').priority, open.priority, "{set}: ・「"); // After a full stop the half em stays, before an opening bracket too. for b in ['漢', '「'] { let a = aki('。', b);