Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 66 additions & 59 deletions Rules/Languages/ja/SharedRules/general.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
- test:
if: "$Verbosity!='Terse'"
then:
- t: "" # phrase('the' square root of 25 equals 5)
- T: "" # phrase('the' square root of 25 equals 5)
- bookmark: "*[2]/@id"
- test:
- if: "*[2][.='+']"
then: [t: "正の"] # phrase(set of all 'positive' integers less than 10)
else: [t: "負の"] # phrase(set of all 'negative' integers less than minus 10)
then: [T: "正の"] # phrase(set of all 'positive' integers less than 10)
else: [T: "負の"] # phrase(set of all 'negative' integers less than minus 10)
- bookmark: "*[1]/@id"
- test:
- if: "*[1][.='ℂ']"
then: [t: "複素数"] # phrase('complex numbers' consist of two parts)
then: [T: "複素数"] # phrase('complex numbers' consist of two parts)
- else_if: "*[1][.='ℕ']"
then: [t: "自然数"] # phrase('natural numbers' are numbers from 1 to infinity)
then: [T: "自然数"] # phrase('natural numbers' are numbers from 1 to infinity)
- else_if: "*[1][.='ℚ']"
then: [t: "有理数"] # phrase('rational numbers' are the fraction of 2 integers)
then: [T: "有理数"] # phrase('rational numbers' are the fraction of 2 integers)
- else_if: "*[1][.='ℝ']"
then: [t: "実数"] # phrase('real numbers' can be both positive and negative)
then: [T: "実数"] # phrase('real numbers' can be both positive and negative)
- else_if: "*[1][.='ℤ']"
then: [t: "整数"] # phrase(positive 'integers' are natural numbers above 0)
then: [T: "整数"] # phrase(positive 'integers' are natural numbers above 0)
else: [x: "*[1][text()]"] # shouldn't happen

- name: dimension-number-sets
Expand Down Expand Up @@ -57,30 +57,30 @@
- bookmark: "@id"
- test:
- if: ".='ℂ'"
then: [t: "複素数"] # phrase('the complex numbers' include 2 parts)
then: [T: "複素数"] # phrase('the complex numbers' include 2 parts)
- else_if: ".='ℕ'"
then: [t: "自然数"] # phrase('the natural numbers' begin at 1)
then: [T: "自然数"] # phrase('the natural numbers' begin at 1)
- else_if: ".='ℚ'"
then: [t: "有理数"] # phrase('the rational numbers' are the fraction of 2 integers)
then: [T: "有理数"] # phrase('the rational numbers' are the fraction of 2 integers)
- else_if: ".='ℝ'"
then: [t: "実数"] # phrase('the real numbers' can be both positive and negative)
then: [T: "実数"] # phrase('the real numbers' can be both positive and negative)
- else_if: ".='ℤ'"
then: [t: "整数"] # phrase('the integers' are natural numbers above 0)
then: [T: "整数"] # phrase('the integers' are natural numbers above 0)
else: [x: "text()"] # shouldn't happen

- name: real-part
tag: real-part
match: "count(*)=0"
replace:
- bookmark: "@id"
- t: "実部" # phrase('the real part' of a complex number does not include the imaginary part)
- T: "実部" # phrase('the real part' of a complex number does not include the imaginary part)

- name: imaginary-part
tag: imaginary-part
match: "count(*)=0"
replace:
- bookmark: "@id"
- t: "虚部" # phrase('the imaginary part' is part of a complex number)
- T: "虚部" # phrase('the imaginary part' is part of a complex number)

# rules on scripted vertical bars ('evaluated at')
- name: evaluated-at-2
Expand Down Expand Up @@ -116,25 +116,32 @@
- x: "*[2]"
- T: "個取る順列"

- name: intervals
- name: intervals # audit-ignore: Japanese names the kind of interval in Japanese instead of speaking the tag, and puts から/まで after the endpoints
tag: [open-interval, open-closed-interval, closed-interval, closed-open-interval]
match: "count(*)=2"
replace:
- test:
if: "$Verbosity!='Terse'"
then:
- t: "" # phrase('the' square root of 25 equals 5)
- x: "translate(name(.),'-', ' ')"
- T: "" # phrase('the' square root of 25 equals 5)
- test:
- if: "name(.)='open-interval'"
then: [T: "開区間"] # phrase(the 'open interval' from a to b)
- else_if: "name(.)='closed-interval'"
then: [T: "閉区間"] # phrase(the 'closed interval' from a to b)
- else_if: "name(.)='open-closed-interval'"
then: [T: "左開右閉区間"] # phrase(the 'open closed interval' from a to b)
else: [T: "左閉右開区間"] # phrase(the 'closed open interval' from a to b)
- test:
if: "$Verbosity!='Terse'"
then:
- t: "から" # phrase(subtracting 5 'from' 10 gives 5)
- x: "*[1]"
- t: "に" # phrase(adding 6 'to' 6 equals 12)
- T: "から" # phrase(subtracting 5 'from' 10 gives 5)
- x: "*[2]"
- T: "まで" # phrase(adding 6 'to' 6 equals 12)
else:
- x: "*[1]"
- t: "コンマ" # phrase(use a 'comma' to divide large numbers or as a decimal point)
- T: "コンマ" # phrase(use a 'comma' to divide large numbers or as a decimal point)
- x: "*[2]"

- name: default-point
Expand All @@ -144,10 +151,10 @@
- test:
if: "$Verbosity!='Terse'"
then:
- t: "" # phrase('the' square root of 25 equals 5)
- T: "" # phrase('the' square root of 25 equals 5)
- T: "点" # phrase(a decimal 'point' indicates the fraction component of a number)
- x: "*[1]"
- t: "コンマ" # phrase(use a 'comma' to divide large numbers or as a decimal point)
- T: "コンマ" # phrase(use a 'comma' to divide large numbers or as a decimal point)
- x: "*[2]"

- name: bigop-both
Expand All @@ -159,13 +166,13 @@
then: [ot: ""] # phrase('the' square root of 25 equals 5)
- x: "*[1]"
- x: "*[2]"
- t: "から" # phrase(subtracting 5 'from' 10 gives 5)
- T: "から" # phrase(subtracting 5 'from' 10 gives 5)
- pause: short
- x: "*[3]"
- t: "まで" # phrase(adding 6 'to' 6 equals 12)
- T: "まで" # phrase(adding 6 'to' 6 equals 12)
- test:
if: "following-sibling::*"
then: [t: "オブ"] # phrase(the square root 'of' 25 equals 5)
then: [T: "オブ"] # phrase(the square root 'of' 25 equals 5)

- name: bigop-under
tag: large-op
Expand All @@ -176,10 +183,10 @@
then: [ot: ""] # phrase('the' square root of 25 equals 5)
- x: "*[1]"
- x: "*[2]"
- t: "にわたる" # phrase(2 'over' 3 equals two thirds)
- T: "にわたる" # phrase(2 'over' 3 equals two thirds)
- test:
if: "following-sibling::*"
then: [t: "オブ"] # phrase(the square root 'of' 25 equals 5)
then: [T: "オブ"] # phrase(the square root 'of' 25 equals 5)

- name: largeop
tag: mrow
Expand All @@ -189,15 +196,15 @@
if: "$Verbosity!='Terse'"
then: [ot: ""] # phrase('the' square root of 25 equals 5)
- x: "*[1]"
- t: "オブ" # phrase(the square root 'of' 25 equals 5)
- T: "オブ" # phrase(the square root 'of' 25 equals 5)
- x: "*[2]"

- name: repeating-decimal
tag: repeating-decimal
match: "."
replace:
- x: "*[1]"
- t: "数字を繰り返して" # phrase('with repeating digits')
- T: "循環節" # phrase('with repeating digits')
- spell: "*[2]"

- name: msubsup-skip-super
Expand Down Expand Up @@ -346,52 +353,52 @@
match: ".='sin'"
replace:
- bookmark: "@id"
- t: "サイン" # phrase(the 'sine' of the angle)
- T: "サイン" # phrase(the 'sine' of the angle)
- name: cos
tag: mi
match: ".='cos'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "コサイン"] # phrase('cos' is the abbreviation for cosine)
else: [t: "コサイン"] # phrase(find the 'cosine' in a right-angle triangle)
then: [T: "コサイン"] # phrase('cos' is the abbreviation for cosine)
else: [T: "コサイン"] # phrase(find the 'cosine' in a right-angle triangle)
- name: tan
tag: mi
match: ".='tan' or .='tg'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "タンジェント"] # phrase(the 'tan' is the ratio of the opposite to the adjacent side of a right-angled triangle)
else: [t: "タンジェント"] # phrase(a 'tangent' is a straight line that touches a curve)
then: [T: "タンジェント"] # phrase(the 'tan' is the ratio of the opposite to the adjacent side of a right-angled triangle)
else: [T: "タンジェント"] # phrase(a 'tangent' is a straight line that touches a curve)
- name: sec
tag: mi
match: ".='sec'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "セカント"] # phrase(to 'seek' a solution)
else: [t: "セカント"] # phrase(a 'secant' intersects a curve at two or more points)
then: [T: "セカント"] # phrase(to 'seek' a solution)
else: [T: "セカント"] # phrase(a 'secant' intersects a curve at two or more points)
- name: csc
tag: mi
match: ".='csc'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "コセカント"] # phrase(we will 'cosecant' a solution)
else: [t: "コセカント"] # phrase(the 'cosecant' is the reciprocal of the secant)
then: [T: "コセカント"] # phrase(we will 'cosecant' a solution)
else: [T: "コセカント"] # phrase(the 'cosecant' is the reciprocal of the secant)
- name: cot
tag: mi
match: ".='cot'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "コタンジェント"] # phrase(find the 'cotangent' in a right-angle triangle)
else: [t: "コタンジェント"] # phrase(the 'cotangent' is the reciprocal of the tangent)
then: [T: "コタンジェント"] # phrase(find the 'cotangent' in a right-angle triangle)
else: [T: "コタンジェント"] # phrase(the 'cotangent' is the reciprocal of the tangent)

- name: sinh
tag: mi
Expand All @@ -400,71 +407,71 @@
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "ハイパーボリックサイン"] # phrase(the word 'sinch' is an abbreviation for hyperbolic sine)
else: [t: "双曲線正弦"] # phrase(the 'hyperbolic sine' is used in mathematics)
then: [T: "ハイパーボリックサイン"] # phrase(the word 'sinch' is an abbreviation for hyperbolic sine)
else: [T: "双曲線正弦"] # phrase(the 'hyperbolic sine' is used in mathematics)
- name: cosh
tag: mi
match: ".='cosh'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "ハイパーボリックコサイン"] # phrase('cosh' is an abbreviation of hyperbolic cosine)
else: [t: "双曲線余弦"] # phrase(the 'hyperbolic cosine' is a mathematical function)
then: [T: "ハイパーボリックコサイン"] # phrase('cosh' is an abbreviation of hyperbolic cosine)
else: [T: "双曲線余弦"] # phrase(the 'hyperbolic cosine' is a mathematical function)
- name: tanh
tag: mi
match: ".='tanh'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "ハイパーボリックタンジェント"] # phrase('tanch' is shorthand for hyperbolic tangent)
else: [t: "双曲線正接"] # phrase('hyperbolic tangent' is a mathematical function)
then: [T: "ハイパーボリックタンジェント"] # phrase('tanch' is shorthand for hyperbolic tangent)
else: [T: "双曲線正接"] # phrase('hyperbolic tangent' is a mathematical function)
- name: sech
tag: mi
match: ".='sech'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "ハイパーボリックセカント"] # phrase('sheck' is shorthand for hyperbolic secant)
else: [t: "双曲線正割"] # phrase('hyperbolic secant' is a mathematical function)
then: [T: "ハイパーボリックセカント"] # phrase('sheck' is shorthand for hyperbolic secant)
else: [T: "双曲線正割"] # phrase('hyperbolic secant' is a mathematical function)
- name: csch
tag: mi
match: ".='csch'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "ハイパーボリックコセカント"] # phrase('cosheck' is shorthand for hyperbolic cosecant)
else: [t: "双曲線余割"] # phrase('hyperbolic cosecant' is a mathematical function)
then: [T: "ハイパーボリックコセカント"] # phrase('cosheck' is shorthand for hyperbolic cosecant)
else: [T: "双曲線余割"] # phrase('hyperbolic cosecant' is a mathematical function)
- name: coth
tag: mi
match: ".='coth'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "ハイパーボリックコタンジェント"] # phrase('cotanch' is shorthand for hyperbolic cotangent)
else: [t: "双曲線余接"] # phrase(the 'hyperbolic cotangent' is a mathematical function)
then: [T: "ハイパーボリックコタンジェント"] # phrase('cotanch' is shorthand for hyperbolic cotangent)
else: [T: "双曲線余接"] # phrase(the 'hyperbolic cotangent' is a mathematical function)
- name: exponential
tag: mi
match: ".='exp'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "指数関数"] # phrase('exp' means exponential function)
else: [t: "指数関数"] # phrase('exponential' function)
then: [T: "指数関数"] # phrase('exp' means exponential function)
else: [T: "指数関数"] # phrase('exponential' function)
- name: covariance
tag: mi
match: ".='Cov'"
replace:
- bookmark: "@id"
- test:
if: "$Verbosity='Terse'"
then: [t: "コーブ"] # phrase('Cov' is shorthand for the covariance function)
else: [t: "コバリアンス"] # phrase('covariance' function)
then: [T: "共分散"] # phrase('Cov' is shorthand for the covariance function)
else: [T: "共分散"] # phrase('covariance' function)

-
name: log # handle log, principal Log, and ln (if in an mrow, 'intents' are used)
Expand All @@ -477,7 +484,7 @@
then: [ot: ""] # phrase('the' logarithm function is used in mathematics)
- test:
- if: ".= 'log'"
then: [t: "ログ"] # phrase(the 'log' function is used in mathematics)
then: [T: "ログ"] # phrase(the 'log' function is used in mathematics)
- else_if: ".= 'Log'"
then: [t: "主値ログ"]
- else_if: "$Verbosity='Terse'"
Expand Down Expand Up @@ -1081,7 +1088,7 @@
tag: none
match: "../../*[self::m:chemical-formula or self::m:chemical-nuclide]"
replace:
- t: "" # don't say anything
- T: "" # don't say anything

- name: ignore-intent-wrapper
tag: intent-wrapper
Expand Down
38 changes: 38 additions & 0 deletions tests/Languages/ja/ja.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,44 @@ fn interval_open_closed() -> Result<()> {
return Ok(());
}

/// SimpleSpeak names the kind of interval. The name was read in English
/// ("open interval から c に d"), and から and まで now follow the endpoints.
/// (a, b] is 左開右閉区間 and [a, b) is 左閉右開区間; 左半開区間 is avoided because
/// authors differ on which side it means.
#[test]
fn simplespeak_interval_names_are_japanese() -> Result<()> {
let cases = [
("open-interval", "(", ")", "開区間"),
("closed-interval", "[", "]", "閉区間"),
("open-closed-interval", "(", "]", "左開右閉区間"),
("closed-open-interval", "[", ")", "左閉右開区間"),
];
for (intent, open, close, name) in cases {
let expr = format!("<math><mrow intent='{intent}($start, $end)'><mo>{open}</mo><mi arg='start'>c</mi><mo>,</mo><mi arg='end'>d</mi><mo>{close}</mo></mrow></math>");
test("ja", "SimpleSpeak", &expr, &format!("{name} c から d まで"))?;
test_prefs("ja", "SimpleSpeak", vec![("Verbosity", "Terse")], &expr, &format!("{name} c コンマ d"))?;
}
return Ok(());
}

/// 循環節 is the dictionary term for the repeating digits of a recurring decimal.
#[test]
fn repeating_decimal_says_junkansetsu() -> Result<()> {
let expr = "<math><mn>0.1</mn><mo>&#x2062;</mo><mover><mn>23</mn><mo>¯</mo></mover></math>";
test("ja", "SimpleSpeak", expr, "0.1 循環節 2 3")?;
test("ja", "ClearSpeak", expr, "0.1 循環節 2 3")?;
return Ok(());
}

/// Cov is 共分散 at every verbosity, as exp is 指数関数 at every verbosity.
#[test]
fn covariance_is_kyoubunsan() -> Result<()> {
let expr = "<math><mrow><mi>Cov</mi><mi>x</mi></mrow></math>";
test("ja", "SimpleSpeak", expr, "共分散 x")?;
test_prefs("ja", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "共分散 x")?;
return Ok(());
}

/// Verifies that an indexed cube root receives the Japanese cube-root cue.
#[test]
fn cube_root() -> Result<()> {
Expand Down
Loading