ja: read fractions in Japanese word order - #720
Open
yasumorishima wants to merge 2 commits into
Open
Conversation
A fraction of two numbers is read denominator-first in Japanese: 21/22 is "22 分の 21". The seeded rules emitted numerator, 分の, denominator, so the tests were asserting that 21/22 is spoken as 22/21. That is a meaning change, not a wording preference, so the rule and its test move together. Reference: 山口雄仁・川根深・澤崎陽彦, 日本語による数式読み上げ法の基本構成に ついて, 日本数学教育学会誌 78(9), 239-247 (1996), item (4): when numerator and denominator are both plain numbers, use ordinary Japanese word order (denominator 分の numerator); otherwise keep the written order and say 分数 A オーバー B 分数終了. Following that split: - common-fraction (both mn, no decimal separator) now says 分母 分の 分子. The English range limits (numerator < 20, denominator 2..10) existed because English only has ordinals for small numbers; Japanese has no separate ordinal form to build, so the pattern is uniform and ToOrdinal is no longer used here. - the remaining fraction rules keep the written order and now say オーバー rather than 分の, which would otherwise claim the opposite order. - ClearSpeak's general fraction said 分子 との 分数 ... デノミネーター; it now uses the same 分数 ... オーバー ... 分数終了 frame. - 分数終わり -> 分数終了, matching the terminology of the reference (and the 根号終了 / 上付き終了 markers that will follow). Also in this file: per-fraction said パーカー, which is a hooded sweatshirt. "5 meters per second" is 5 メートル 毎 秒.
The previous commit widened common-fraction, but ClearSpeak copies that predicate in five other places: the EndFrac test inside fraction-over-simple (twice, for numerator and denominator) and the four nested-* exponent rules that ask whether the base is a common fraction. Left alone, 3/128 would count as a common fraction where it is spoken and not count where those rules look, so the two would disagree. The copies now use the same test: both children are mn without a decimal separator. The English range limits (numerator < 20, denominator 2..10) are gone for the same reason as before -- they bound what English has ordinals for, and Japanese builds no ordinal form. No wording changes here; the phrasing of the exponent rules themselves is a separate change.
This was referenced Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of the small PRs promised in #715. It fixes the one item in the seeded Japanese that changes the meaning of the maths rather than the wording.
The problem
simple_fractionasserted 21/22 → 「21 分の 22」. In Japanese 「A 分の B」 is B/A — the denominator is spoken first — so the seeded rules and the seeded test agreed with each other that 21/22 should be spoken as 22/21.The rule I followed
If numerator and denominator are both plain numbers, use ordinary Japanese word order (denominator 分の numerator). Otherwise keep the written order and say 分数 A オーバー B 分数終了. Katsuhito Yamaguchi is behind ChattyInfty / InftyReader, the math TTS actually used by blind students in Japan.
Changes
common-fractionin both ClearSpeak and SimpleSpeak now emits*[2]分の*[1].text()<20,2 <= text() <= 10) andToOrdinal(..., true(), ...)there. Those exist because English only has ordinals for small numbers; Japanese builds no separate ordinal form, so one pattern covers any pair of numbers.per-fractionsaid パーカー, which is a hooded sweatshirt. "5 meters per second" is 5 メートル 毎 秒.One definition, five copies
ClearSpeak copies the "both parts are plain numbers" predicate in five other places: the
EndFractest insidefraction-over-simple(twice, numerator and denominator) and the fournested-*exponent rules that ask whether the base is a common fraction.grep -c "text()<20"gave 5 injaagainst 6 inen. Withcommon-fractionwidened and the copies left alone, 3/128 would have counted as a common fraction where it is spoken and not counted where those rules look, so the second commit brings all five to the same test.No new tests for the
nested-*shapes here: their wording (「に上げられた … パワー」) is itself wrong Japanese and belongs to the next PR, so pinning it now would only have to be rewritten.Tests
simple_fractionupdated, and it now checks SimpleSpeak as well as ClearSpeak. Addednumeric_fraction_large_denominator(3/128 — outside the old English ordinal range) andfraction_of_variables(x/y → x オーバー y, both styles).One thing to flag
This makes
audit-translations jareport 5 rule differences wherejacurrently reports 0 (measured both ways on this branch and onja). They are the changed match pattern and the removedvariables: [IsPlural: ...]incommon-fractionandcommon-fraction-mixed-number.The divergence is deliberate: those guards and that variable encode English morphology that Japanese does not have. @moritz-gross — you offered to help with
audit-translations, so rather than opening a separate issue: is structural divergence fromensomething a language is allowed to do, or would you prefer the rule shape kept identical with the body made a no-op? I will follow whichever you want.