Skip to content

Commit 0a45c33

Browse files
Merge branch 'NSoiffer:main' into main
2 parents b722a71 + 2db040b commit 0a45c33

28 files changed

Lines changed: 279 additions & 92 deletions

Rules/Intent/general.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,10 @@
581581

582582
# Pseudo-script characters are characters such as "degree sign" ('°') that are raised but in MathML should be in a superscript.
583583
# They are not spoken as if in a superscript (e.g "x degrees", not "x superscripts degrees")
584-
585584
-
586585
name: skip-super
587586
tag: [msup, msubsup]
588-
match: "*[last()][translate(., '′″‴⁗†‡°*', '')='']"
587+
match: "*[last()][translate(., '′″‴⁗\"†‡°*', '')='' or .=\"'\"]" # you can't have both ' and " in an xpath string
589588
replace:
590589
- intent:
591590
name: "skip-super"

Rules/Languages/en/ClearSpeak_Rules.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@
131131
# Units (e.g., meters per second)
132132
- name: per-fraction
133133
tag: fraction
134-
match: "$ClearSpeak_Fractions='Per' or
135-
BaseNode(*[1])[contains(@data-intent-property, ':unit') or (self::m:mrow and self::*[3][contains(@data-intent-property, ':unit')])] and
136-
BaseNode(*[1])[contains(@data-intent-property, ':unit') or (self::m:mrow and self::*[3][contains(@data-intent-property, ':unit')])]"
134+
match:
135+
- "$ClearSpeak_Fractions='Per' or"
136+
- "(BaseNode(*[1])[contains(@data-intent-property, ':unit') or"
137+
- " ( self::m:mrow and count(*)=3 and" # maybe a bit paranoid checking the structure...
138+
- " *[1][self::m:mn] and *[2][.='\u2062'] and BaseNode(*[3])[contains(@data-intent-property, ':unit')] ) ] and"
139+
- " BaseNode(*[2])[contains(@data-intent-property, ':unit')] )"
137140
replace:
138141
- x: "*[1]"
139142
- t: "per" # phrase('5 meters 'per' second)

Rules/Languages/en/SharedRules/general.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,20 @@
238238
tag: unit
239239
match: "$Verbosity != 'Terse' and contains(@data-intent-property, ':unit')"
240240
variables:
241-
# we need to look at preceding-sibling::*[2] because invisible times should have been added
242-
# if in a fraction, only count if we are in the numerator
243-
- IsSingular: "(parent::m:mrow and preceding-sibling::*[2][self::m:mn and . = 1]) or
244-
(ancestor::*[2][self::m:mrow] and parent::m:fraction and
245-
(preceding-sibling::* or parent::*[preceding-sibling::*[2][self::m:mn and . = 1]])
246-
)"
241+
# If the coefficient is singular, we don't add the plural ending. Finding the coefficient is tricky
242+
# Normal case (A) "3m" (parents is mrow), but could also be (B) "3 m^2" (etc.) (parent is power/mrow)
243+
# But it might be in a fraction as (C) "3 m/s" (parent is fraction/mrow) or (D) "3 m^2/s^2" (parent is power/fraction/mrow)
244+
# or even (E) {3 m^2}/s (parent is power/mrow)
245+
# If in a fraction, only look in the numerator to find the coefficient
246+
# Note: we have a special case for pseudo-scripts like "°" (degrees) which are not powers -- they are essentially "1^°"
247+
# The following "IfThenElse" logic returns the mrow that potentially contains the coefficient, if it exists
248+
# The tests are in the order A, B & E, C, D
249+
- MRowForCoefficient: "IfThenElse(parent::m:mrow, parent::m:mrow,
250+
IfThenElse(parent::m:power, ancestor::*[2][self::m:mrow],
251+
IfThenElse(parent::m:fraction and not(preceding-sibling::*), ancestor::*[2][self::m:mrow],
252+
IfThenElse(parent::m:power[parent::m:fraction and not(preceding-sibling::*)], ancestor::*[3][self::m:mrow], false()) ) ) )"
253+
- IsSingular: "(not(DEBUG($MRowForCoefficient)) and parent::*[name(.)!='skip-super' or *[1][.=1]]) or
254+
($MRowForCoefficient and $MRowForCoefficient[(count(*) = 3 and *[1][self::m:mn and .=1] and *[2]='\u2062')])"
247255
- Prefix: "''"
248256
- Word: "''"
249257
replace:

Rules/Languages/en/SimpleSpeak_Rules.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,14 @@
102102
- x: "ToOrdinal(*[2], true(), $IsPlural)" # extra args specify fractional ordinal and whether it is plural
103103

104104

105-
# Units (e.g., meters per second)
105+
# Units (e.g., meters per second, m^2/s^2, (3m^2)/s)
106106
- name: per-fraction
107107
tag: fraction
108-
match: "BaseNode(*[1])[contains(@data-intent-property, ':unit') or (self::m:mrow and self::*[3][contains(@data-intent-property, ':unit')])] and
109-
BaseNode(*[1])[contains(@data-intent-property, ':unit') or (self::m:mrow and self::*[3][contains(@data-intent-property, ':unit')])]"
108+
match:
109+
- "BaseNode(*[1])[contains(@data-intent-property, ':unit') or"
110+
- " ( self::m:mrow and count(*)=3 and" # maybe a bit paranoid checking the structure...
111+
- " *[1][self::m:mn] and *[2][.='\u2062'] and BaseNode(*[3])[contains(@data-intent-property, ':unit')] ) ] and"
112+
- "BaseNode(*[2])[contains(@data-intent-property, ':unit')] "
110113
replace:
111114
- x: "*[1]"
112115
- t: "per" # phrase('5 meters 'per' second)

Rules/Languages/en/definitions.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
"absolute-value": "function= ; absolute value: the absolute value: the absolute value; end absolute value",
1919
"binomial": "infix=binomial; choose; end binomial",
20+
"dimension-product": "infix=by",
2021
# "closed-interval": "other=closed-interval; from,to; end closed-interval",
2122
"greatest-common-divisor": "function=gcd: the gcd: the greatest common divisor",
2223
"imaginary-part": "function=imaginary part, the imaginary part, the imaginary part",
@@ -49,8 +50,8 @@
4950

5051
"chemistry-concentration": "function= ; concentration: concentration of: the concentration of; end concentration",
5152
}
52-
# Names of functions that in terse mode don't say "of" (or it's equivalent in other languages)
5353

54+
# Names of functions that in terse mode don't say "of" (or it's equivalent in other languages)
5455
- TerseFunctionNames: {
5556
"divergence", "gradient", "curl"
5657
}
@@ -81,11 +82,6 @@
8182
"out": "out of",
8283
}
8384

84-
- OperatorIntentRenaming: {
85-
# These are the intents that are renamed to something else (probably most intents for non-English languages)
86-
"dimension-product": "by"
87-
}
88-
8985
- KnownWords: {
9086
# MathCAT will put together some runs of three or more mi's (a common mistake), but skips those in alphabetical order.
9187
# This is a list of exceptions so that they do get put together. Don't list words with repeated letters.

Rules/Languages/es/ClearSpeak_Rules.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,15 @@
117117
# Units (e.g., meters per second)
118118
- name: per-fraction
119119
tag: fraction
120-
match: "$ClearSpeak_Fractions='Per'"
120+
match:
121+
- "$ClearSpeak_Fractions='Per' or"
122+
- "(BaseNode(*[1])[contains(@data-intent-property, ':unit') or"
123+
- " ( self::m:mrow and count(*)=3 and" # maybe a bit paranoid checking the structure...
124+
- " *[1][self::m:mn] and *[2][.='\u2062'] and BaseNode(*[3])[contains(@data-intent-property, ':unit')] ) ] and"
125+
- " BaseNode(*[2])[contains(@data-intent-property, ':unit')] )"
121126
replace:
122127
- x: "*[1]"
123-
- T: "por"
128+
- t: "por" # phrase('5 meters 'per' second)
124129
- x: "*[2]"
125130

126131
- name: common-fraction

Rules/Languages/es/SharedRules/general.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,17 @@
228228
tag: unit
229229
match: "$Verbosity != 'Terse' and contains(@data-intent-property, ':unit')"
230230
variables:
231-
# we need to look at preceding-sibling::*[2] because invisible times should have been added
232-
# if in a fraction, only count if we are in the numerator
233-
- IsSingular: "(parent::m:mrow and preceding-sibling::*[2][self::m:mn and . = 1]) or
234-
(ancestor::*[2][self::m:mrow] and parent::m:fraction and
235-
(preceding-sibling::* or parent::*[preceding-sibling::*[2][self::m:mn and . = 1]])
236-
)"
231+
# If the coefficient is singular, we don't add the plural ending. Finding the coefficient is tricky
232+
# Normal case (A) "3m" (parents is mrow), but could also be (B) "3 m^2" (etc.). (parent is msup/mrow)
233+
# But it might be in a fraction as (C) "3 m/s" (parent is mfrac/mrow) or (D) "3 m^2/s^2" (parent is msup/mfrac/mrow)
234+
# or even (E) {3 m^2}/s (parent is msup/mrow)
235+
# If in a fraction, only look in the numerator to find the coefficient
236+
- MRowForCoefficient: "IfThenElse(parent::m:mrow, parent::m:mrow,
237+
IfThenElse(parent::m:power, ancestor::*[2][self::m:mrow],
238+
IfThenElse(parent::m:fraction and not(preceding-sibling::*), ancestor::*[2][self::m:mrow],
239+
IfThenElse(parent::m:power[parent::m:fraction and not(preceding-sibling::*)], ancestor::*[3][self::m:mrow], false()) ) ) )"
240+
- IsSingular: "(not(DEBUG($MRowForCoefficient)) and parent::*[name(.)!='skip-super' or *[1][.=1]]) or
241+
($MRowForCoefficient and $MRowForCoefficient[(count(*) = 3 and *[1][self::m:mn and .=1] and *[2]='\u2062')])"
237242
- Prefix: "''"
238243
- Word: "''"
239244
replace:

Rules/Languages/es/SimpleSpeak_Rules.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@
8181
- "*[2][self::m:mn][not(contains(., '.'))]"
8282
replace: [{x: ToCommonFraction(.)}]
8383

84+
85+
# Units (e.g., meters per second, m^2/s^2, (3m^2)/s)
86+
- name: per-fraction
87+
tag: fraction
88+
match:
89+
- "BaseNode(*[1])[contains(@data-intent-property, ':unit') or"
90+
- " ( self::m:mrow and count(*)=3 and" # maybe a bit paranoid checking the structure...
91+
- " *[1][self::m:mn] and *[2][.='\u2062'] and BaseNode(*[3])[contains(@data-intent-property, ':unit')] ) ] and"
92+
- "BaseNode(*[2])[contains(@data-intent-property, ':unit')] "
93+
replace:
94+
- x: "*[1]"
95+
- t: "por" # phrase('5 meters 'per' second)
96+
- x: "*[2]"
97+
8498
- name: simple
8599
# don't include nested fractions. E.g, fraction a plus b over c + 1 end fraction" is ambiguous
86100
# by simplistic SimpleSpeak's rules "b over c" is a fraction, but if we say nested fractions

Rules/Languages/fi/SharedRules/general.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,20 @@
292292
tag: unit
293293
match: "$Verbosity != 'Terse' and contains(@data-intent-property, ':unit')"
294294
variables:
295-
# we need to look at preceding-sibling::*[2] because invisible times should have been added
296-
# if in a fraction, only count if we are in the numerator
297-
- IsSingular: "(parent::m:mrow and preceding-sibling::*[2][self::m:mn and . = 1]) or
298-
(ancestor::*[2][self::m:mrow] and parent::m:fraction and
299-
(preceding-sibling::* or parent::*[preceding-sibling::*[2][self::m:mn and . = 1]])
300-
)"
295+
# If the coefficient is singular, we don't add the plural ending. Finding the coefficient is tricky
296+
# Normal case (A) "3m" (parents is mrow), but could also be (B) "3 m^2" (etc.) (parent is power/mrow)
297+
# But it might be in a fraction as (C) "3 m/s" (parent is fraction/mrow) or (D) "3 m^2/s^2" (parent is power/fraction/mrow)
298+
# or even (E) {3 m^2}/s (parent is power/mrow)
299+
# If in a fraction, only look in the numerator to find the coefficient
300+
# Note: we have a special case for pseudo-scripts like "°" (degrees) which are not powers -- they are essentially "1^°"
301+
# The following "IfThenElse" logic returns the mrow that potentially contains the coefficient, if it exists
302+
# The tests are in the order A, B & E, C, D
303+
- MRowForCoefficient: "IfThenElse(parent::m:mrow, parent::m:mrow,
304+
IfThenElse(parent::m:power, ancestor::*[2][self::m:mrow],
305+
IfThenElse(parent::m:fraction and not(preceding-sibling::*), ancestor::*[2][self::m:mrow],
306+
IfThenElse(parent::m:power[parent::m:fraction and not(preceding-sibling::*)], ancestor::*[3][self::m:mrow], false()) ) ) )"
307+
- IsSingular: "(not(DEBUG($MRowForCoefficient)) and parent::*[name(.)!='skip-super' or *[1][.=1]]) or
308+
($MRowForCoefficient and $MRowForCoefficient[(count(*) = 3 and *[1][self::m:mn and .=1] and *[2]='\u2062')])"
301309
- Prefix: "''"
302310
- Word: "''"
303311
replace:

Rules/Languages/fi/SimpleSpeak_Rules.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@
9292
- x: "*[1]"
9393
- x: "ToOrdinal(*[2], true(), $IsPlural)" # extra args specify fractional ordinal and whether it is plural
9494

95+
# Units (e.g., meters per second, m^2/s^2, (3m^2)/s)
96+
- name: per-fraction
97+
tag: fraction
98+
match:
99+
- "BaseNode(*[1])[contains(@data-intent-property, ':unit') or"
100+
- " ( self::m:mrow and count(*)=3 and" # maybe a bit paranoid checking the structure...
101+
- " *[1][self::m:mn] and *[2][.='\u2062'] and BaseNode(*[3])[contains(@data-intent-property, ':unit')] ) ] and"
102+
- "BaseNode(*[2])[contains(@data-intent-property, ':unit')] "
103+
replace:
104+
- x: "*[1]"
105+
- x: "*[2]"
106+
- t: "kohti" # phrase('5 meters 'per' second)
107+
95108
- name: simple
96109
# don't include nested fractions. E.g, fraction a plus b over c + 1 end fraction" is ambiguous
97110
# by simplistic SimpleSpeak's rules "b over c" is a fraction, but if we say nested fractions

0 commit comments

Comments
 (0)