Skip to content

Commit 2fbafc7

Browse files
Oppdatering
1 parent 79ddcab commit 2fbafc7

File tree

11 files changed

+2418
-2213
lines changed

11 files changed

+2418
-2213
lines changed

Rules/Languages/nb/ClearSpeak_Rules.yaml

Lines changed: 66 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
then:
2323
- bookmark: "*[1]/@id"
2424
- test:
25-
if: parent::*[self::m:negative]
26-
then: [{T: "negativt"}] # phrase(minus 4 is a 'negative' number)
27-
else: [{T: "positivt"}] # phrase(10 is a 'positive' number)
25+
if: parent::*[self::m:minus and count(*)=1]
26+
then: [{T: "den negative"}] # phrase(minus 4 is a 'negative' number)
27+
else: [{T: "den positive"}] # phrase(10 is a 'positive' number)
2828
- test:
2929
if: "$Verbosity!='Terse'"
3030
then: {T: "kvadratroten av"} # phrase(the square root 'of' 5)
@@ -48,24 +48,25 @@
4848
if: $ClearSpeak_Roots = 'PosNegSqRoot' or $ClearSpeak_Roots = 'PosNegSqRootEnd'
4949
then:
5050
- test:
51-
if: "parent::m:negative or parent::m:positive"
51+
if: "parent::*[(self::m:minus or self::m:plus) and count(*)=1]"
5252
then: [{bookmark: "parent/@id"}]
5353
- test:
54-
if: parent::m:negative
55-
then: [{T: "negativt"}] # phrase(minus 6 is a 'negative' number)
56-
else: [{T: "positivt"}] # phrase(10 is a 'positive' number)
54+
if: parent::m:minus
55+
then: [{T: "den negative"}] # phrase(minus 6 is a 'negative' number)
56+
else: [{T: "den positive"}] # phrase(10 is a 'positive' number)
5757
- test:
5858
if: "*[2][self::m:mn]"
5959
then_test:
60-
- if: "*[2][text()='2']"
60+
- if: "*[2][.='2']"
6161
then: {T: "kvadratroten"} # phrase(5 is the 'square root' of 25)
62-
- else_if: "*[2][text()='3']"
62+
- else_if: "*[2][.='3']"
6363
then: {T: "kubikkroten"} # phrase(5 is the 'cube root' of 625)
6464
- else_if: "*[2][not(contains(., ','))]" # SWEDISH: Changed decimal point to comma.
6565
then: [{x: "ToOrdinal(*[2])"}, {T: "roten"}] # phrase(the square 'root' of 25)
6666
else:
6767
- T: "roten av grad" # phrase(the square 'root' of 36)
6868
- x: "*[2]"
69+
- pause: short
6970
# SWEDISH: Removed verbosity settings.
7071
- T: "av" # phrase(the square root 'of' 36)
7172
- x: "*[1]"
@@ -82,8 +83,8 @@
8283

8384
# The 'negative' rule interacts with the msqrt/mroot rules as those might pick off this case ("the negative square root of x")
8485
- name: negative_and_positive
85-
tag: [negative, positive]
86-
match: "."
86+
tag: [plus, minus]
87+
match: "count(*)=1 and contains(@data-intent-property, ':prefix:')"
8788
replace:
8889
- test:
8990
if:
@@ -93,7 +94,7 @@
9394
else:
9495
- bookmark: "@id"
9596
- test:
96-
if: "self::m:negative"
97+
if: "self::m:minus"
9798
then: [{T: "minus"}] # phrase(minus 5 is a 'negative' number)
9899
else: [{T: "pluss"}] # phrase(7 is a 'positive' number)
99100
- x: "*[1]"
@@ -104,7 +105,9 @@
104105
# Units (e.g., meters per second)
105106
- name: per-fraction
106107
tag: fraction
107-
match: "$ClearSpeak_Fractions='Per'"
108+
match: "$ClearSpeak_Fractions='Per' or
109+
BaseNode(*[1])[contains(@data-intent-property, ':unit') or (self::m:mrow and self::*[3][contains(@data-intent-property, ':unit')])] and
110+
BaseNode(*[1])[contains(@data-intent-property, ':unit') or (self::m:mrow and self::*[3][contains(@data-intent-property, ':unit')])]"
108111
replace:
109112
- x: "*[1]"
110113
- T: "per" # phrase('5 meters 'per' second)
@@ -119,28 +122,30 @@
119122
# SWEDISH: Alternative logic for handling correct reading out of common fractions.
120123
variables: [IsPlural: "*[1]!=1"]
121124
replace:
122-
- pause: short
123-
- test:
124-
if: "*[1]=1"
125-
then: [T: "en"]
126-
else: [x: "*[1]"]
125+
#- pause: short
126+
#- test:
127+
#if: "*[1]=1"
128+
#then: [T: "en"]
129+
#else: [x: "*[1]"]
130+
- x: "*[1]"
127131
- x: "ToOrdinal(*[2], true(), $IsPlural)" # extra args specify fractional ordinal and whether it is plural
128132

129133
- name: common-fraction-mixed-number
130134
tag: fraction
131135
match:
132-
- "preceding-sibling::*[1][self::m:mo][text()='⁤'] and" # preceding element is invisible plus
136+
- "preceding-sibling::*[1][self::m:mo][.='⁤'] and" # preceding element is invisible plus
133137
- "($ClearSpeak_Fractions='Auto' or $ClearSpeak_Fractions='Ordinal' or $ClearSpeak_Fractions='EndFrac') and"
134138
- "*[1][self::m:mn][not(contains(., ',')) and ($ClearSpeak_Fractions='Ordinal' or text()<20)] and"
135139
- "*[2][self::m:mn][not(contains(., ',')) and ($ClearSpeak_Fractions='Ordinal' or (2<= text() and text()<=10))]"
136140
# SWEDISH: Alternative logic for handling correct reading out of common fractions.
137141
variables: [IsPlural: "*[1]!=1"]
138142
replace:
139-
- pause: short
140-
- test:
141-
if: "*[1]=1"
142-
then: [T: "en"]
143-
else: [x: "*[1]"]
143+
#- pause: short
144+
#- test:
145+
#if: "*[1]=1"
146+
#then: [T: "en"]
147+
#else: [x: "*[1]"]
148+
- x: "*[1]"
144149
- x: "ToOrdinal(*[2], true(), $IsPlural)" # extra args specify fractional ordinal and whether it is plural
145150

146151
- name: fraction-over-simple
@@ -177,12 +182,12 @@
177182
- " ((*[1][self::m:mi or self::m:mtext][string-length(.)>1]) or " # fractions with text
178183
- " (*[1][self::m:mrow][count(*)=3][ "
179184
- " *[1][self::m:mn] and "
180-
- " *[2][self::m:mo][text()='⁢'] and " # invisible times
185+
- " *[2][self::m:mo][.='⁢'] and " # invisible times
181186
- " *[3][self::m:mi or self::m:mtext][string-length(.)>1] ]) ) and"
182187
- " ((*[2][self::m:mi or self::m:mtext][string-length(.)>1]) or " # fractions with text
183188
- " (*[2][self::m:mrow][count(*)=3][ "
184189
- " *[1][self::m:mn] and "
185-
- " *[2][self::m:mo][text()='⁢'] and " # invisible times
190+
- " *[2][self::m:mo][.='⁢'] and " # invisible times
186191
- " *[3][self::m:mi or self::m:mtext][string-length(.)>1] ]) )"
187192
- ")"
188193
replace:
@@ -229,27 +234,27 @@
229234
then: [{x: "*[1]"}, {bookmark: "*[2]/@id"}, {T: "invers"}] # phrase(8 over 5 is the 'inverse' of 5 over 8)
230235
else_test:
231236
if: $ClearSpeak_Trig = 'ArcTrig'
232-
then: [{bookmark: "*[2]/@id"}, {T: "buelenge"}, {x: "*[1]"}] # phrase(the 'buelenge' of a circle)
237+
then: [{bookmark: "*[2]/@id"}, {T: "arcus"}, {x: "*[1]"}] # phrase(the 'buelenge' of a circle)
233238
else: [{bookmark: "*[2]/@id"}, {T: "invers"}, {x: "*[1]"}] # default/Auto # phrase(8 over 5 is the 'inverse' of 5 over 8)
234239

235240

236241
- name: function-squared-or-cubed
237242
tag: power
238243
match:
239-
- "*[2][self::m:mn][text()='2' or text()='3'] and"
240-
- "following-sibling::*[1][self::m:mo][text()='⁡']" #invisible function apply
244+
- "*[2][self::m:mn][.='2' or .='3'] and"
245+
- "following-sibling::*[1][self::m:mo][.='⁡']" #invisible function apply
241246
replace:
242247
- x: "*[1]"
243248
- bookmark: "*[2]/@id"
244249
- test:
245-
if: "*[2][text()='2']"
250+
if: "*[2][.='2']"
246251
then: {T: "i andre"} # phrase(25 equals 5 'squared') #Marthe: "sin^2x sin kvadrert av x"
247252
else: {T: "i tredje"} # phrase(625 equals 5 'cubed')
248253

249254
- name: function-power
250255
tag: power
251256
match:
252-
- "following-sibling::*[1][self::m:mo][text()='⁡']" #invisible function apply
257+
- "following-sibling::*[1][self::m:mo][.='⁡']" #invisible function apply
253258
replace:
254259
- x: "*[1]"
255260
- T: "opphøyd i"
@@ -281,15 +286,15 @@
281286

282287
- name: squared
283288
tag: power
284-
match: "*[2][self::m:mn][text()='2'] and $ClearSpeak_Exponents = 'Auto'"
289+
match: "*[2][self::m:mn][.='2'] and $ClearSpeak_Exponents = 'Auto'"
285290
replace:
286291
- x: "*[1]"
287292
- bookmark: "*[2]/@id"
288293
- T: "i andre" # phrase(7 'squared' equals 49) #Marthe: "7 kvadrert, 7^2"
289294

290295
- name: cubed
291296
tag: power
292-
match: "*[2][self::m:mn][text()='3'] and $ClearSpeak_Exponents = 'Auto'"
297+
match: "*[2][self::m:mn][.='3'] and $ClearSpeak_Exponents = 'Auto'"
293298
replace:
294299
- x: "*[1]"
295300
- bookmark: "*[2]/@id"
@@ -308,7 +313,7 @@
308313
- name: simple-negative-integer
309314
tag: power
310315
match:
311-
- "*[2][self::m:negative and"
316+
- "*[2][self::m:minus and count(*)=1 and"
312317
- " *[1][self::m:mn][not(contains(., ','))]"
313318
- " ]"
314319
replace:
@@ -342,7 +347,7 @@
342347
match:
343348
- "$ClearSpeak_Exponents = 'Auto' and"
344349
- "*[2][self::m:power]["
345-
- " *[2][self::m:mn][text()='2' or text()='3'] and " # exp is 2 or 3
350+
- " *[2][self::m:mn][.='2' or .='3'] and " # exp is 2 or 3
346351
# base is mn, mi, common fraction ([xxx] case)
347352
- " *[1][self::m:mn or self::m:mi or "
348353
- " self::m:fraction[*[1][self::m:mn][not(contains(., ',')) and text()<20] and"
@@ -359,9 +364,9 @@
359364
tag: power
360365
match:
361366
- "$ClearSpeak_Exponents = 'Auto' and"
362-
- " *[2][self::m:negative and "
367+
- " *[2][self::m:minus and count(*)=1 and "
363368
- " *[1]/*[1][self::m:power]["
364-
- " *[2][self::m:mn][text()='2' or text()='3'] and " # exp is 2 or 3"
369+
- " *[2][self::m:mn][.='2' or .='3'] and " # exp is 2 or 3"
365370
# base is mn, mi, common fraction ([xxx] case)
366371
- " *[1][self::m:mn or self::m:mi or "
367372
- " self::m:fraction[*[1][self::m:mn][not(contains(., ',')) and text()<20] and"
@@ -381,10 +386,10 @@
381386
- "$ClearSpeak_Exponents = 'Auto' and"
382387
- " *[2][self::m:mrow][count(*)=3][ "
383388
- " *[3][self::m:power]["
384-
- " *[2][self::m:mn][text()='2' or text()='3'] and " # exp is 2 or 3
389+
- " *[2][self::m:mn][.='2' or .='3'] and " # exp is 2 or 3
385390
- " *[1][self::m:mi]"
386391
- " ] and "
387-
- " *[2][self::m:mo][text()='⁢'] and " # invisible times
392+
- " *[2][self::m:mo][.='⁢'] and " # invisible times
388393
# base is mn, or common fraction ([xxx] case)
389394
- " *[1][self::m:mn or "
390395
- " self::m:fraction[*[1][self::m:mn][not(contains(., ',')) and text()<20] and"
@@ -403,11 +408,11 @@
403408
- "$ClearSpeak_Exponents = 'Auto' and"
404409
- " *[2][self::m:mrow][count(*)=3][ "
405410
- " *[3][self::m:power]["
406-
- " *[2][self::m:mn][text()='2' or text()='3'] and " # exp is 2 or 3
411+
- " *[2][self::m:mn][.='2' or .='3'] and " # exp is 2 or 3
407412
- " *[1][self::m:mi]"
408413
- " ] and "
409-
- " *[2][self::m:mo][text()='⁢'] and " # invisible times
410-
- " *[1][self::m:negative and "
414+
- " *[2][self::m:mo][.='⁢'] and " # invisible times
415+
- " *[1][self::m:minus and count(*)=1 and "
411416
# base is mn, or common fraction ([xxx] case)
412417
- " *[1][self::m:mn or "
413418
- " self::m:fraction[*[1][self::m:mn][not(contains(., ',')) and text()<20] and"
@@ -476,7 +481,7 @@
476481
if: "$Verbosity!='Terse'"
477482
then: {T: "den"} # phrase('the' empty set)
478483
- T: "tomme mengden" # phrase(the 'empty set')
479-
- else_if: "count(*[1]/*)=3 and *[1]/*[2][self::m:mo][text()=':' or text()='|' or text()='∣']"
484+
- else_if: "count(*[1]/*)=3 and *[1]/*[2][self::m:mo][.=':' or .='|' or .='∣']"
480485
then:
481486
- T: "mengden av" # phrase(this is a 'set of' numbers)
482487
- test:
@@ -501,8 +506,8 @@
501506
# SWEDISH: rewrote the intervals function to better deal with Swedish convention of speaking intervals
502507
- name: ClearSpeak-intervals # avoid overriding with default "intervals" name
503508
variables:
504-
- is_intervals_start_infinity: "*[1][self::m:negative and *[1][text()='∞']]"
505-
- is_intervals_end_infinity: "*[2][text()='∞'or (self::m:positive and *[1][text()='∞'])]"
509+
- is_intervals_start_infinity: "*[1][self::m:minus and count(*)=1 and *[1][.='∞']]"
510+
- is_intervals_end_infinity: "*[2][text()='∞'or (self::m:plus and count(*)=1 and *[1][.='∞'])]"
506511
tag: [open-interval, open-closed-interval, closed-interval, closed-open-interval]
507512
match: "."
508513
replace:
@@ -562,28 +567,28 @@
562567
variables: [{log_is_simple: "IsNode(*[3],'simple')"}]
563568
match:
564569
- "count(*)=3 and"
565-
- "*[1][self::m:mi][text()='log' or text()='ln' or text()='lg'] and"
566-
- "*[2][self::m:mo][text()='⁡']"
570+
- "*[1][self::m:mi][.='log' or .='ln' or .='lg'] and"
571+
- "*[2][self::m:mo][.='⁡']"
567572
replace:
568573
- test:
569574
if: "$log_is_simple"
570575
then_test:
571-
- if: "*[1][text()='log']"
576+
- if: "*[1][.='log']"
572577
then: [{T: "log"}] # phrase(the 'log' of x)
573-
- else_if: "*[1][text()='lg']"
578+
- else_if: "*[1][.='lg']"
574579
then: [{spell: "'lg'"}] # phrase(the 'lg' of x)
575580
- else_if: $ClearSpeak_Log = 'LnAsNaturalLog'
576581
then: [{T: "den naturlige logaritmen"}] # phrase(the 'natural log' of the product of 2 numbers)
577582
else: [{spell: "'ln'"}]
578583
else:
579584
- test:
580-
- if: "*[1][text()='log']"
585+
- if: "*[1][.='log']"
581586
then:
582587
- test:
583588
- if: "$Verbosity='Verbose'"
584589
then: [{T: "logaritmen"}]
585590
else: [{T: "log"}]
586-
- else_if: "*[1][text()='lg']"
591+
- else_if: "*[1][.='lg']"
587592
then:
588593
- test:
589594
- if: "$Verbosity='Verbose'"
@@ -592,9 +597,10 @@
592597
- else_if: $ClearSpeak_Log = 'LnAsNaturalLog' or $Verbosity='Verbose'
593598
then: [{T: "den naturlige logaritmen"}] # phrase(the 'natural log' of x)
594599
else: [{spell: "'ln'"}]
595-
- test:
596-
- if: "$Verbosity='Verbose'"
597-
then: [{T: "av"}] # phrase(the natural log 'of' x)
600+
#- test:
601+
#- if: "$Verbosity='Verbose'"
602+
#then: [{T: "av"}] # phrase(the natural log 'of' x)
603+
- T: "av"
598604
- pause: short
599605
- x: "*[3]"
600606

@@ -687,7 +693,7 @@
687693
- name: ClearSpeak_Functions_None
688694
tag: mo
689695
match:
690-
- "text()='⁡' and $ClearSpeak_Functions = 'None' and"
696+
- ".='⁡' and $ClearSpeak_Functions = 'None' and"
691697
- "not(preceding-sibling::*[1][IsInDefinition(., 'TrigFunctionNames')])" # Functions=None does not apply to "trig" functions
692698
replace:
693699
test:
@@ -699,7 +705,7 @@
699705
tag: mo
700706
match:
701707
# Note: this rule is also part of the paren rule so that the parens speak
702-
- "text()='⁢' and $ClearSpeak_ImpliedTimes = 'None'"
708+
- ".='⁢' and $ClearSpeak_ImpliedTimes = 'None'"
703709
replace:
704710
- T: ""
705711

@@ -708,13 +714,14 @@
708714
match:
709715
# say "times" when invisible times is followed by parens or a superscript that has a base with parens or "|"s
710716
# if we aren't sure if it is times or not, don't say anything
711-
- "text()='⁢' and (not(@data-function-guess) or $ClearSpeak_Functions = 'None') and"
717+
- ".='⁢' and (not(@data-function-guess) or $ClearSpeak_Functions = 'None') and"
712718
- "not(ancestor-or-self::*[contains(@data-intent-property, ':structure:')]) and ("
713719
- " $ClearSpeak_ImpliedTimes = 'MoreImpliedTimes'"
714720
- " or "
715721
- " following-sibling::*[1]["
716722
- " IsBracketed(., '(', ')') or IsBracketed(., '[', ']') or IsBracketed(., '|', '|') or "
717723
- " self::m:matrix or self::m:determinant or self::m:binomial or" # followed by parens
724+
- " self::m:square-root or self::m:msqrt or self::m:root or self::m:mroot or"
718725
- " ( (self::m:msup or self::m:msub or self::m:msubsup or self::m:power) and " # followed by msup, etc.
719726
- " *[1][self::m:mrow[IsBracketed(., '(', ')') or IsBracketed(., '[', ']') or IsBracketed(., '|', '|')] or "
720727
- " self::m:matrix or self::m:determinant]" # base has parens
@@ -736,9 +743,9 @@
736743
- " not(self::m:math) ] and " # rule out [x] standing alone
737744
- "( IsBracketed(., '(', ')') or IsBracketed(., '[', ']') ) and "
738745
- "not( $ClearSpeak_Functions = 'None' and "
739-
- " (preceding-sibling::*[1][text()='⁡'] or following-sibling::*[1][text()='⁡']) ) and "
746+
- " (preceding-sibling::*[1][.='⁡'] or following-sibling::*[1][.='⁡']) ) and "
740747
- "not( $ClearSpeak_ImpliedTimes = 'None' and "
741-
- " (preceding-sibling::*[1][text()='⁢'] or following-sibling::*[1][text()='⁢']) ) and "
748+
- " (preceding-sibling::*[1][.='⁢'] or following-sibling::*[1][.='⁢']) ) and "
742749
- "IsNode(*[2], 'simple') and"
743750
- "not(ancestor-or-self::*[contains(@data-intent-property, ':structure:')])"
744751
# missing clause: 'a positive fraction that is spoken as an ordinal

Rules/Languages/nb/SharedRules/calculus.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
replace:
77
- test:
88
if: "$Verbosity='Verbose'"
9-
then: [t: "divergence"] # phrase('divergence' from the mean)
10-
else: [t: "div"] # phrase('divergence' from the mean)
11-
- t: "of" # phrase(systems 'of' linear equations)
9+
then: [T: "divergensen til"] # phrase('divergence' from the mean)
10+
else: [T: "div"] # phrase('divergence' from the mean)
1211
- test:
1312
if: "not(IsNode(*[1], 'leaf'))"
1413
then: [pause: short]
@@ -18,7 +17,10 @@
1817
tag: curl
1918
match: "."
2019
replace:
21-
- t: "curl of" # phrase(the 'curl of' a field)
20+
- test:
21+
if: "$Verbosity='Verbose'"
22+
then: [T: "curlen til"]
23+
else: [T: "curl"]
2224
- test:
2325
if: "not(IsNode(*[1], 'leaf'))"
2426
then: [pause: short]
@@ -28,10 +30,7 @@
2830
tag: gradient
2931
match: "."
3032
replace:
31-
- test:
32-
if: "$Verbosity!='Terse'"
33-
then: [t: "gradient of"] # phrase('divergence' from the mean)
34-
else: [t: "del"] # phrase('divergence' from the mean)
33+
- T: "gradienten til"
3534
- test:
3635
if: "not(IsNode(*[1], 'leaf'))"
3736
then: [pause: short]

0 commit comments

Comments
 (0)