diff --git a/Rules/Languages/ja/ClearSpeak_Rules.yaml b/Rules/Languages/ja/ClearSpeak_Rules.yaml
index e35ed066..f020db63 100644
--- a/Rules/Languages/ja/ClearSpeak_Rules.yaml
+++ b/Rules/Languages/ja/ClearSpeak_Rules.yaml
@@ -252,25 +252,20 @@
- bookmark: "*[2]/@id"
- test:
if: "*[2][.='2']"
- then: [t: "スクエア"] # phrase(25 equals 5 'squared')
- else: [t: "キューブド"] # phrase(625 equals 5 'cubed')
+ then: [t: "の 2 乗"] # phrase(25 equals 5 'squared')
+ else: [t: "の 3 乗"] # phrase(625 equals 5 'cubed')
- name: function-power
tag: power
match:
- "following-sibling::*[1][self::m:mo][.='']" #invisible function apply
replace:
- - test:
- if: "$Verbosity!='Terse'"
- then: [ot: ""] # phrase('the' third power of 2)
+ - x: "*[1]"
+ - t: "の" # phrase(the third 'power of' 6)
- bookmark: "*[2]/@id"
- - test:
- if: "*[2][self::m:mn][not(contains(., '.'))]"
- then: [x: "ToOrdinal(*[2])"]
- else: [x: "*[2]"]
- - t: "パワーの" # phrase(the third 'power of' 6)
+ - x: "*[2]"
+ - t: "乗" # phrase(the third 'power of' 6)
- pause: short
- - x: "*[1]"
- name: AfterPower-nested
tag: power
@@ -279,19 +274,20 @@
- "*[2][self::m:power or self::m:power or self::m:mrow[m:power]]"
replace:
- x: "*[1]"
- - t: "緊急事態に育つ" # phrase(5 'raised to the exponent' x plus 1)
+ - t: "の上付き" # phrase(5 'raised to the exponent' x plus 1)
- pause: short
- x: "*[2]"
- pause: short
- - t: "エンド指数" # phrase(5 raised to the exponent x plus 1 'end exponent')
+ - t: "上付き終了" # phrase(5 raised to the exponent x plus 1 'end exponent')
- name: AfterPower-default
tag: power
match: "$ClearSpeak_Exponents = 'AfterPower'"
replace:
- x: "*[1]"
- - t: "力に育つ" # phrase(x is 'raised to the power' 4)
+ - t: "の" # phrase(x is 'raised to the power' 4)
- x: "*[2]"
+ - t: "乗" # phrase(x is raised to the 'power' 4)
- pause: short
- name: squared
@@ -300,7 +296,7 @@
replace:
- x: "*[1]"
- bookmark: "*[2]/@id"
- - t: "スクエア" # phrase(7 'squared' equals 49)
+ - t: "の 2 乗" # phrase(7 'squared' equals 49)
- name: cubed
tag: power
@@ -308,7 +304,7 @@
replace:
- x: "*[1]"
- bookmark: "*[2]/@id"
- - t: "キューブド" # phrase(5 'cubed' equals 125)
+ - t: "の 3 乗" # phrase(5 'cubed' equals 125)
- name: simple-integer
tag: power
@@ -316,13 +312,8 @@
replace:
- x: "*[1]"
- t: "の" # phrase(2 raised 'to the' power 7)
- - test:
- if: "*[2][.>0]"
- then: [x: "ToOrdinal(*[2])"]
- else: [x: "*[2]"]
- - test:
- if: "$ClearSpeak_Exponents != 'Ordinal'"
- then: [t: "パワー"] # phrase(2 raised to the 'power' 7)
+ - x: "*[2]"
+ - t: "乗" # phrase(2 raised to the 'power' 7)
- name: simple-negative-integer
tag: power
@@ -334,9 +325,7 @@
- x: "*[1]"
- t: "の" # phrase(2 raised 'to the' power 7)
- x: "*[2]"
- - test:
- if: "$ClearSpeak_Exponents != 'Ordinal'"
- then: [t: "パワー"] # phrase(2 raised to the 'power' 7)
+ - t: "乗" # phrase(2 raised to the 'power' 7)
- name: simple-var
tag: power
@@ -345,10 +334,7 @@
- x: "*[1]"
- t: "の" # phrase(3 raised 'to the' power 7)
- x: "*[2]"
- - pronounce: [text: "-th", ipa: "θ", sapi5: "th", eloquence: "T"]
- - test:
- if: "$ClearSpeak_Exponents != 'Ordinal'"
- then: [t: "パワー"] # phrase(2 raised to the 'power' 7)
+ - t: "乗" # phrase(2 raised to the 'power' 7)
# match nested exponent, where the nested exponent is has the power 2 or 3 (n below)
# [xxx]^n, - [xxx]^n, [xxx] var^n, -[xxx] var^n
@@ -373,9 +359,9 @@
- " ]"
replace:
- x: "*[1]"
- - t: "に上げられた" # phrase(x 'raised to the' second power)
+ - t: "の上付き" # phrase(x 'raised to the' second power)
- x: "*[2]"
- - t: "パワー" # phrase(x raised to the second 'power')
+ - t: "上付き終了" # phrase(x raised to the second 'power')
- # - [xxx]^n
name: nested-negative-squared-or-cubed
@@ -394,9 +380,9 @@
- " ]"
replace:
- x: "*[1]"
- - t: "に上げられた" # phrase(x 'raised to the' second power)
+ - t: "の上付き" # phrase(x 'raised to the' second power)
- x: "*[2]"
- - t: "パワー" # phrase(x raised to the second 'power')
+ - t: "上付き終了" # phrase(x raised to the second 'power')
- # [xxx] var^n
name: nested-var-squared-or-cubed
@@ -417,9 +403,9 @@
- " ]"
replace:
- x: "*[1]"
- - t: "に上げられた" # phrase(x 'raised to the' second power)
+ - t: "の上付き" # phrase(x 'raised to the' second power)
- x: "*[2]"
- - t: "パワー" # phrase(x raised to the second 'power')
+ - t: "上付き終了" # phrase(x raised to the second 'power')
- # -[xxx] var^n
name: nested-negative-var-squared-or-cubed
@@ -442,9 +428,9 @@
- " ]"
replace:
- x: "*[1]"
- - t: "に上げられた" # phrase(x 'raised to the' second power)
+ - t: "の上付き" # phrase(x 'raised to the' second power)
- x: "*[2]"
- - t: "パワー" # phrase(x raised to the second 'power')
+ - t: "上付き終了" # phrase(x raised to the second 'power')
- name: default-exponent-power
tag: power
@@ -452,20 +438,20 @@
- "*[2][self::m:power or self::m:power or self::m:mrow[m:power]]"
replace:
- x: "*[1]"
- - t: "緊急事態に育つ" # phrase(x is 'raised to the exponent')
+ - t: "の上付き" # phrase(x is 'raised to the exponent')
- pause: short
- x: "*[2]"
- pause: short
- - t: "エンド指数" # phrase(and now 'end exponent' has been reached)
+ - t: "上付き終了" # phrase(and now 'end exponent' has been reached)
- name: default
tag: power
match: "."
replace:
- x: "*[1]"
- - t: "に上げられた" # phrase(x 'raised to the' second power)
+ - t: "の上付き" # phrase(x 'raised to the' second power)
- x: "*[2]"
- - t: "パワー" # phrase(x raised to the second 'power')
+ - t: "上付き終了" # phrase(x raised to the second 'power')
#
# Some rules on mrows
diff --git a/Rules/Languages/ja/SimpleSpeak_Rules.yaml b/Rules/Languages/ja/SimpleSpeak_Rules.yaml
index 235bc266..6a255373 100644
--- a/Rules/Languages/ja/SimpleSpeak_Rules.yaml
+++ b/Rules/Languages/ja/SimpleSpeak_Rules.yaml
@@ -172,24 +172,19 @@
- bookmark: "*[2]/@id"
- test:
if: "*[2][.=2]"
- then: [t: "スクエア"] # phrase(5 'squared' equals 25)
- else: [t: "キューブド"] # phrase(5 'cubed' equals 125)
+ then: [t: "の 2 乗"] # phrase(5 'squared' equals 25)
+ else: [t: "の 3 乗"] # phrase(5 'cubed' equals 125)
- name: function-power
tag: power
match:
- "following-sibling::*[1][self::m:mo][.='']" #invisible function apply
replace:
- - test:
- if: "$Verbosity!='Terse'"
- then: [ot: ""] # # phrase('the' fourth power of 10)
+ - x: "*[1]"
+ - t: "の" # phrase(the fourth 'power of' 2)
- bookmark: "*[2]/@id"
- - test:
- if: "*[2][self::m:mn][not(contains(., '.'))]"
- then: [x: "ToOrdinal(*[2])"]
- else: [x: "*[2]"]
- - t: "パワーの" # phrase(the fourth 'power of' 2)
+ - x: "*[2]"
+ - t: "乗" # phrase(the fourth 'power of' 2)
- pause: short
- - x: "*[1]"
# non-function rules for power
- name: squared-or-cubed
@@ -200,8 +195,8 @@
- bookmark: "*[2]/@id"
- test:
if: "*[2][.=2]"
- then: [t: "スクエア"] # phrase(5 'squared' equals 25)
- else: [t: "キューブド"] # phrase(5 'cubed' equals 125)
+ then: [t: "の 2 乗"] # phrase(5 'squared' equals 25)
+ else: [t: "の 3 乗"] # phrase(5 'cubed' equals 125)
- name: simple-integer
tag: power
@@ -209,10 +204,9 @@
replace:
- x: "*[1]"
- t: "の" # phrase(15 raised 'to the' second power equals 225)
- - test:
- if: "*[2][.>0]"
- then: [x: "ToOrdinal(*[2])"]
- else: [x: "*[2]"]
+ - x: "*[2]"
+ - t: "乗" # phrase(15 raised to the second 'power' equals 225)
+
- name: simple-negative-integer
tag: power
match:
@@ -222,6 +216,8 @@
- x: "*[1]"
- t: "の" # phrase(15 raised 'to the' second power equals 225)
- x: "*[2]"
+ - t: "乗" # phrase(15 raised to the second 'power' equals 225)
+
- name: simple-var
tag: power
match: "*[2][self::m:mi][string-length(.)=1]"
@@ -229,7 +225,7 @@
- x: "*[1]"
- t: "の" # phrase(15 raised 'to the' second power equals 225)
- x: "*[2]"
- - pronounce: [text: "-th", ipa: "θ", sapi5: "th", eloquence: "T"]
+ - t: "乗" # phrase(15 raised to the second 'power' equals 225)
- name: simple
tag: power
@@ -238,6 +234,7 @@
- x: "*[1]"
- t: "の" # phrase(15 raised 'to the' second power equals 225)
- x: "*[2]"
+ - t: "乗" # phrase(15 raised to the second 'power' equals 225)
- name: nested
# it won't end in "power" if the exponent is simple enough
@@ -251,13 +248,13 @@
- " ]"
replace:
- x: "*[1]"
- - t: "に上げられた" # phrase(15 'raised to the' second power equals 225)
+ - t: "の上付き" # phrase(15 'raised to the' second power equals 225)
- x: "*[2]"
- pause: short
- test:
if: "$Impairment = 'Blindness'"
then:
- - t: "エンド指数" # phrase(start 2 raised to the exponent 4 'end of exponent')
+ - t: "上付き終了" # phrase(start 2 raised to the exponent 4 'end of exponent')
- pause: short
else:
- pause: medium
@@ -267,9 +264,9 @@
match: "."
replace:
- x: "*[1]"
- - t: "に上げられた" # phrase(15 'raised to the' second power equals 225)
+ - t: "の上付き" # phrase(15 'raised to the' second power equals 225)
- x: "*[2]"
- - t: "パワー" # phrase(15 raised to the second 'power' equals 225)
+ - t: "上付き終了" # phrase(15 raised to the second 'power' equals 225)
- pause: short
#
diff --git a/tests/Languages/ja/ja.rs b/tests/Languages/ja/ja.rs
index 44f4c2f2..0d82d706 100644
--- a/tests/Languages/ja/ja.rs
+++ b/tests/Languages/ja/ja.rs
@@ -25,11 +25,49 @@ fn square_root() -> Result<()> {
return Ok(());
}
-/// Verifies that a squared value uses the seeded Japanese exponent wording.
+/// An exponent is read " の 乗"; 乗 closes it. Japanese has no
+/// ordinal form here, so 2 is 2 and not "second".
#[test]
fn squared() -> Result<()> {
let expr = "";
- test("ja", "ClearSpeak", expr, "3 スクエア")?;
+ test("ja", "ClearSpeak", expr, "3 の 2 乗")?;
+ test("ja", "SimpleSpeak", expr, "3 の 2 乗")?;
+ return Ok(());
+}
+
+/// Same shape for a cube.
+#[test]
+fn cubed() -> Result<()> {
+ let expr = "";
+ test("ja", "ClearSpeak", expr, "5 の 3 乗")?;
+ test("ja", "SimpleSpeak", expr, "5 の 3 乗")?;
+ return Ok(());
+}
+
+/// The pattern does not change for exponents above three.
+#[test]
+fn integer_exponent() -> Result<()> {
+ let expr = "";
+ test("ja", "ClearSpeak", expr, "x の 5 乗")?;
+ test("ja", "SimpleSpeak", expr, "x の 5 乗")?;
+ return Ok(());
+}
+
+/// A variable exponent is read the same way (English adds "-th" here; Japanese does not).
+#[test]
+fn variable_exponent() -> Result<()> {
+ let expr = "";
+ test("ja", "ClearSpeak", expr, "x の n 乗")?;
+ test("ja", "SimpleSpeak", expr, "x の n 乗")?;
+ return Ok(());
+}
+
+/// A complex exponent is read as a superscript instead, with an explicit close:
+/// 「の上付き … 上付き終了」. Reading it as 乗 would end a nested exponent 「… 乗 乗」.
+#[test]
+fn complex_exponent() -> Result<()> {
+ let expr = "";
+ test("ja", "SimpleSpeak", expr, "x の上付き y プラス 1 上付き終了")?;
return Ok(());
}