diff --git a/Rules/Languages/sv/ClearSpeak_Rules.yaml b/Rules/Languages/sv/ClearSpeak_Rules.yaml index 12c90c02..bbec4476 100644 --- a/Rules/Languages/sv/ClearSpeak_Rules.yaml +++ b/Rules/Languages/sv/ClearSpeak_Rules.yaml @@ -1,4 +1,19 @@ --- +- name: pause + tag: "!*" + match: "not(self::m:math) and not($MatchingPause) and @data-intent-property[contains(., ':pause')]" + replace: + - with: + variables: [MatchingPause: "true()"] + replace: + - test: + - if: "contains(@data-intent-property, ':pause-long')" + then: [pause: long] + - else_if: "contains(@data-intent-property, ':pause-short')" + then: [pause: short] + else: [pause: medium] + - x: "." + - name: intent-literal-silent tag: [mi, mo, mn] match: "contains(@data-intent-property, ':silent:')" diff --git a/Rules/Languages/sv/SharedRules/calculus.yaml b/Rules/Languages/sv/SharedRules/calculus.yaml index 20fcd91c..4e6a9e9c 100644 --- a/Rules/Languages/sv/SharedRules/calculus.yaml +++ b/Rules/Languages/sv/SharedRules/calculus.yaml @@ -1,14 +1,30 @@ --- +- name: laplacian + tag: laplacian + match: "count(*) <= 1" # can be on ∇^2 or on enclosing mrow + replace: + - T: "Laplaceoperatorn" # phrase('laplacian' of x) + - test: + if: "count(*) = 1" + then: + - test: + if: "$Verbosity!='Terse'" + then: [T: "av"] # phrase(function 'of' one variable) + - test: + if: "not(IsNode(*[1], 'leaf'))" + then: [pause: short] + - x: "*[1]" + - name: divergence tag: divergence match: "." replace: - test: if: "$Verbosity='Verbose'" - then: [t: "divergence"] # phrase('divergence' from the mean) - else: [t: "div"] # phrase('divergence' from the mean) - - t: "of" # phrase(systems 'of' linear equations) + then: [T: "divergens"] # phrase('divergence' from the mean) + else: [T: "div"] # phrase('divergence' from the mean) + - T: "av" # phrase(systems 'of' linear equations) - test: if: "not(IsNode(*[1], 'leaf'))" then: [pause: short] @@ -18,7 +34,7 @@ tag: curl match: "." replace: - - t: "curl of" # phrase(the 'curl of' a field) + - T: "rotationen av" # phrase(the 'curl of' a field) - test: if: "not(IsNode(*[1], 'leaf'))" then: [pause: short] @@ -30,8 +46,8 @@ replace: - test: if: "$Verbosity!='Terse'" - then: [t: "gradient of"] # phrase('divergence' from the mean) - else: [t: "del"] # phrase('divergence' from the mean) + then: [T: "gradienten av"] # phrase('divergence' from the mean) + else: [T: "grad"] # phrase('divergence' from the mean) - test: if: "not(IsNode(*[1], 'leaf'))" then: [pause: short] diff --git a/Rules/Languages/sv/SharedRules/general.yaml b/Rules/Languages/sv/SharedRules/general.yaml index 6f23a162..d6b4d420 100644 --- a/Rules/Languages/sv/SharedRules/general.yaml +++ b/Rules/Languages/sv/SharedRules/general.yaml @@ -213,6 +213,14 @@ - T: "av" # phrase(the square root 'of' 25 equals 5) - x: "*[2]" +- name: repeating-decimal + tag: repeating-decimal + match: "." + replace: + - x: "*[1]" + - T: "med repeterande siffror" # phrase('with repeating digits') + - spell: "*[2]" + - name: msubsup-skip-super # handles single, double, etc., prime tag: [skip-super, say-super] @@ -275,6 +283,14 @@ replace: - x: "IfThenElse($NeuterUnitFollows, 'ett', 1)" +# in terse mode, we just say "m" or "s", etc., not meters or seconds +- name: unit-terse + tag: unit + match: "$Verbosity = 'Terse' and string-length(.)=1" + replace: + - bookmark: "@id" + - spell: "text()" + # the order of matching is # 1. does it match the base of an SI unit # 2. does it match an English unit (if in an English language) @@ -498,6 +514,26 @@ then: [T: "cotan hype"] # phrase('cotanch' is shorthand for hyperbolic cotangent) else: [T: "cotangens hyperbolicus"] # phrase(the 'hyperbolic cotangent' is a mathematical function) +- name: exponential + tag: mi + match: ".='exp'" + replace: + - bookmark: "@id" + - test: + if: "$Verbosity='Terse'" + then: [T: "exp"] # phrase('exp' means exponential function) + else: [T: "exponentialfunktionen"] # phrase('exponential' function) + +- name: covariance + tag: mi + match: ".='Cov'" + replace: + - bookmark: "@id" + - test: + if: "$Verbosity='Terse'" + then: [T: "Cov"] # phrase('Cov' is shorthand for the covariance function) + else: [T: "kovarians"] # phrase('covariance' function) + - # handle both log and ln name: log tag: mi @@ -631,6 +667,57 @@ - T: "med element" # phrase(the 2 by 2 matrix 'with entry' x) - x: "*[1]/*" +# enklare uppläsning för specialfall av matriser +- name: zero-matrix + tag: matrix + # select all the non-zero entries -- if there are none of them, then it is a zero matrix + match: "not( */*/*[not(self::m:mn and .= 0)] )" + replace: + - x: count(*) + - T: "gånger" # phrase(the 1 'by' 2 matrix) + - x: count(*[self::m:mtr][1]/*) + - T: "nollmatris" # phrase(the 2 by 2 'zero matrix') + - pause: long + +- name: identity-matrix + tag: matrix + # select all the non-zero entries...if they are not on the diagonal, or are != 1 + # if there are any of them, then this isn't an identity matrix + match: + - "count(*) = count(*[1]/*) and " + - "not( */*/*[not(self::m:mn and .= 0)]" + - " [count(../preceding-sibling::*)!=count(../../preceding-sibling::*) or .!= 1]" + - " )" + replace: + - x: count(*) + - T: "gånger" # phrase(the 1 'by' 2 matrix) + - x: count(*[self::m:mtr][1]/*) + - T: "identitetsmatris" # phrase(the 2 by 2 'identity matrix') + - pause: long + +- name: diagonal-matrix + tag: matrix + # select all the non-zero entries...if they are not on the diagonal + # if there are any of them, then this isn't an identity matrix + match: + - "count(*) = count(*[1]/*) and " + - "not( */*/*[not(self::m:mn and .= 0)]" + - " [count(../preceding-sibling::*)!=count(../../preceding-sibling::*)]" + - " )" + replace: + - x: count(*) + - T: "gånger" # phrase(the 1 'by' 2 matrix) + - x: count(*[self::m:mtr][1]/*) + - T: "diagonalmatris" # phrase(the 2 by 2 'diagonal matrix') + - pause: long + - insert: + # this lists the diagonal 'mtd's to be read, and they say "column nnn" before reading the contents + # there seems to be an xpath bug -- without the parens, the match fails for the + # test Languages::en::mtable::diagonal_matrix due to match failure (the third matching element seems to be missing) + nodes: "(*/*/*[not(self::m:mn and .= 0)]/..)" + replace: [pause: auto] + - pause: long + # simpler reading methods for smaller matrices if the entries are simple - name: 2-or-3x1-matrix tag: matrix @@ -791,6 +878,14 @@ then: [T: "nedsänkt"] # phrase(H 'sub' 2) - x: "*[3]" +- name: dimension-by + tag: mrow + match: dimension-product + replace: + - insert: + nodes: "*" + replace: [T: "gånger", pause: auto] # phrase(3 'by' 5 matrix) + - name: chemistry-msup tag: [chemical-formula] match: "count(*)=3 and *[1][.='msup']" diff --git a/Rules/Languages/sv/SharedRules/geometry.yaml b/Rules/Languages/sv/SharedRules/geometry.yaml index b6393d37..7de43acb 100644 --- a/Rules/Languages/sv/SharedRules/geometry.yaml +++ b/Rules/Languages/sv/SharedRules/geometry.yaml @@ -54,3 +54,19 @@ - x: "*[2]" - x: "*[3]" +- name: coordinate + tag: coordinate + match: "." + replace: + - T: "punkten" # phrase(the 'point' at 1, 2) + - test: + if: "$Verbosity='Verbose'" + then: [T: "i"] # phrase(the point 'at' 1, 2) + - pause: short + - insert: + nodes: "*" + replace: [T: "komma", pause: auto] # phrase(f of x 'comma' y) + - pause: short + - test: + if: "($SpeechStyle='ClearSpeak' and $Verbosity='Verbose') or not(IsNode(*[last()],'leaf'))" + then: [T: "slutpunkt"] # phrase(start point, 'end point') diff --git a/Rules/Languages/sv/SimpleSpeak_Rules.yaml b/Rules/Languages/sv/SimpleSpeak_Rules.yaml index 36caefc2..eee7d080 100644 --- a/Rules/Languages/sv/SimpleSpeak_Rules.yaml +++ b/Rules/Languages/sv/SimpleSpeak_Rules.yaml @@ -1,5 +1,20 @@ --- +- name: pause + tag: "!*" + match: "not(self::m:math) and not($MatchingPause) and @data-intent-property[contains(., ':pause')]" + replace: + - with: + variables: [MatchingPause: "true()"] + replace: + - test: + - if: "contains(@data-intent-property, ':pause-long')" + then: [pause: long] + - else_if: "contains(@data-intent-property, ':pause-short')" + then: [pause: short] + else: [pause: medium] + - x: "." + - name: intent-literal-silent tag: [mi, mo, mn] match: "contains(@data-intent-property, ':silent:')" @@ -56,6 +71,17 @@ # Fraction rules # Mixed numbers mostly "just work" because the invisible char reads as "and" and other parts read properly on their own # Note: if the bounds change for what is a common fraction, change them in general.yaml for units +- name: common-fraction-mixed-number + tag: fraction + match: + - "preceding-sibling::*[1][self::m:mo][.='⁤'] and" # preceding element is invisible plus + - "*[1][self::m:mn][not(contains(., $DecimalSeparators))] and" + - "*[2][self::m:mn][not(contains(., $DecimalSeparators))]" + variables: [IsPlural: "*[1]!=1"] + replace: + - x: "*[1]" + - x: "ToOrdinal(*[2], true(), $IsPlural)" # extra args specify fractional ordinal and whether it is plural + - name: common-fraction tag: fraction match: