--- # number-sets are a little messy in that the base was converted to a number-set, so we have to match that (simple) case last - name: pos-neg-number-sets tag: number-sets match: "count(*)=2 and *[2][text()='+' or text()='-']" replace: - test: if: "$Verbosity!='Terse'" then: - T: "" # phrase('the' square root of 25 equals 5) - bookmark: "*[2]/@id" - test: - if: "*[2][text()='+']" then: [{T: "positiiviset"}] # phrase(set of all 'positive' integers less than 10) else: [{T: "negatiiviset"}] # phrase(set of all 'negative' integers less than minus 10) - bookmark: "*[1]/@id" - test: - if: "*[1][text()='ℂ']" then: [{T: "kompleksiluvut"}] # phrase('complex numbers' consist of two parts) - else_if: "*[1][text()='ℕ']" then: [{T: "luonnolliset luvut"}] # phrase('natural numbers' are numbers from 1 to infinity) - else_if: "*[1][text()='ℚ']" then: [{T: "rationaaliluvut"}] # phrase('rational numbers' are the fraction of 2 integers) - else_if: "*[1][text()='ℝ']" then: [{T: "reaaliluvut"}] # phrase('real numbers' can be both positive and negative) - else_if: "*[1][text()='ℤ']" then: [{T: "kokonaisluvut"}] # phrase(positive 'integers' are natural numbers above 0) else: [{x: "*[1][text()]"}] # shouldn't happen - name: dimension-number-sets # should be single digit integer at this point (e.g, R^3) tag: number-sets match: "count(*)=2" replace: - bookmark: "*[1]/@id" - test: - if: "*[1][text()='ℂ']" then: [{T: "C"}] # phrase(the letter 'C' used to represent complex number) - else_if: "*[1][text()='ℕ']" then: [{T: "N"}] # phrase(the letter 'N' may represent natural numbers) - else_if: "*[1][text()='ℚ']" then: [{T: "Q"}] # phrase(the letter 'Q' may represent rational numbers) - else_if: "*[1][text()='ℝ']" then: [{T: "R"}] # phrase(the letter 'R' may represent real numbers) - else_if: "*[1][text()='ℤ']" then: [{T: "Z"}] # phrase(the letter 'Z' may represent integers) else: [{x: "*[1][text()]"}] # shouldn't happen - bookmark: "*[2]/@id" - x: "*[2]" - name: simple-number-sets tag: number-sets match: "count(*)=0" replace: - bookmark: "@id" - test: - if: "text()='ℂ'" then: [{T: "kompleksiluvut"}] # phrase('the complex numbers' include 2 parts) - else_if: "text()='ℕ'" then: [{T: "luonnolliset luvut"}] # phrase('the natural numbers' begin at 1) - else_if: "text()='ℚ'" then: [{T: "rationaaliluvut"}] # phrase('the rational numbers' are the fraction of 2 integers) - else_if: "text()='ℝ'" then: [{T: "reaaliluvut"}] # phrase('the real numbers' can be both positive and negative) - else_if: "text()='ℤ'" then: [{T: "kokonaisluvut"}] # phrase('the integers' are natural numbers above 0) else: [x: "text()"] # shouldn't happen - name: real-part tag: real-part match: "." replace: - bookmark: "@id" - T: "reaaliosa" # phrase('the real part' of a complex number does not include the imaginary part) - name: imaginary-part tag: imaginary-part match: "." replace: - bookmark: "@id" - T: "imaginaariosa" # phrase('the imaginary part' is part of a complex number) # rules on scripted vertical bars ('evaluated at') - name: evaluated-at-2 tag: evaluate match: "count(*)=2" replace: - x: "*[1]" - pause: auto - T: "sijoitus" # phrase(results were 'evaluated at' a given point) - pause: auto - x: "*[2]" - name: evaluated-at-3 tag: evaluate match: "count(*)=3" replace: - x: "*[1]" - pause: auto - T: "sijoitus" # phrase(results were 'evaluated at' this point) - pause: auto - x: "*[3]" - T: "miinus sama lauseke arvolla" # phrase(this result is 'minus the same expression evaluated at' an earlier point) - x: "*[2]" - name: binomial tag: binomial match: "count(*)=2 and not(@data-intent-property)" replace: - x: "*[1]" - T: "yli" # phrase(you can 'choose' a number at random) - x: "*[2]" - name: permutation tag: permutation-symbol match: "count(*)=2 and not(@data-intent-property)" replace: - x: "*[2]" - T: "permutaatio" # phrase(the solution involves several 'permutations of' values) - x: "*[1]" - name: intervals tag: [open-interval, open-closed-interval, closed-interval, closed-open-interval] match: "count(*)=2 and not(@data-intent-property)" replace: - test: if: "$Verbosity!='Terse'" then: - T: "" # phrase('the' square root of 25 equals 5) # - x: "translate(name(.),'-', ' ')" # FI: The translate function doesn't work for non-English. Used the solution below instead. - test: - if: "self::m:open-interval" then: [T: "avoin väli"] - else_if: "self::m:open-closed-interval" then: [T: "vasemmalta puoliavoin väli"] - else_if: "self::m:closed-interval" then: [T: "suljettu väli"] - else_if: "self::m:closed-open-interval" then: [T: "oikealta puoliavoin väli"] - test: if: "$Verbosity!='Terse'" then: - T: "luvusta" # FI: "from number", needs a better translation for anything else than a number, maybe this could be omitted - x: "*[1]" - T: "lukuun" # FI: "to number" - x: "*[2]" else: - x: "*[1]" - T: "pilkku" # phrase(use a 'comma' to divide large numbers or as a decimal point) - x: "*[2]" - name: default-point tag: point match: "count(*)=2 and not(@data-intent-property)" replace: - test: if: "$Verbosity!='Terse'" then: - T: "" # phrase('the' square root of 25 equals 5) - T: "piste" # phrase(a decimal 'point' indicates the fraction component of a number) - x: "*[1]" - T: "pilkku" # phrase(use a 'comma' to divide large numbers or as a decimal point) - x: "*[2]" - name: absolute-value tag: absolute-value match: "count(*)=1 and not(@data-intent-property)" replace: - test: if: "$Verbosity='Terse'" then: [{T: "itseisarvo"}] # phrase(the 'absolute value' of a number represents its distance from 0) else: [{T: "itseisarvo"}] # phrase('the absolute value of' a number represents its distance from 0) - x: "*[1]" - test: if: "IsNode(*[1], 'leaf') or $Impairment != 'Blindness'" then: [{pause: short}] else: [{pause: short}, {T: "loppu itseisarvo"}, {pause: short}] # phrase(show 'end absolute value' position) - name: negative tag: negative match: "count(*)=1 and not(@data-intent-property)" replace: - bookmark: "./@id" - T: "negatiivinen" # phrase('negative' infinity) - x: "*[1]" - name: positive tag: positive match: "count(*)=1 and not(@data-intent-property)" replace: - bookmark: "./@id" - T: "positiivinen" # phrase(multiplying two negatives results in a 'positive' number) - x: "*[1]" - name: subscript tag: sub match: "count(*)=2 and not(@data-intent-property)" replace: - x: "*[1]" - T: "ala" # phrase(the subscripted variable a 'sub' i) - x: "*[2]" - test: if: "DEBUG(not(IsNode(*[2],'leaf')))" then: - test: if: "$Verbosity='Verbose'" then: {T: "loppu alaindeksi"} # phrase(this is the 'end subscript' position) else: {T: "loppu ala"} # phrase(this is the 'end sub' position) - pause: short else_test: if: "*[2][self::m:mi]" # need a pause in "x sub k prime" so the prime is not associated with the 'k' then: [pause: short] - name: integral-both tag: large-op match: "count(*)=3 and *[1][.='∫']" replace: - x: "*[1]" - pause: short - T: "alaraja" # FI: integral 'lower bound' upper bound function f(x) - x: "*[2]" - pause: short - T: "yläraja" # FI: integral lower bound 'upper bound' function f(x) - x: "*[3]" - test: if: "following-sibling::*" then: pause: medium - name: bigop-both tag: large-op match: "count(*) = 3" replace: - test: if: "$Verbosity!='Terse'" then: [{T: ""}] # phrase('the' square root of 25 equals 5) - x: "*[1]" - T: "käy" # phrase(subtracting 5 'from' 10 gives 5) - pause: short # FI: added pause for clarity - T: "luvusta" - x: "*[2]" - pause: short # FI: added pause for clarity - T: "lukuun" # phrase(adding 6 'to' 6 equals 12) - x: "*[3]" - test: if: "following-sibling::*" # then: [{T: ""}] # phrase(the square root 'of' 25 equals 5) then: pause: medium - name: bigop-under tag: large-op match: "count(*)=2 and not(@data-intent-property)" replace: - test: if: "$Verbosity!='Terse'" then: [{T: ""}] # phrase('the' square root of 25 equals 5) - x: "*[1]" - T: "yli" # phrase(2 'over' 3 equals two thirds) - x: "*[2]" - test: if: "following-sibling::*" # then: [{T: ""}] # phrase(the square root 'of' 25 equals 5) then: pause: short # FI: added for Finnish, needs a test - name: largeop tag: mrow match: "count(*)=2 and IsInDefinition(*[1], 'LargeOperators')" replace: - test: if: "$Verbosity!='Terse'" then: [{T: ""}] # phrase('the' square root of 25 equals 5) - x: "*[1]" - T: "" # phrase(the square root 'of' 25 equals 5) - x: "*[2]" - name: limit tag: limit match: "count(*)=2 and not(@data-intent-property)" replace: - test: if: "$Verbosity!='Terse'" then: [{T: "raja-arvo kun"}] # phrase('the limit as' indicated by this result) else: [{T: "raja-arvo"}] # phrase(the 'limit as' indicated by this result) - x: "*[2]" - pause: short - name: vector tag: modified-variable match: "count(*)=2 and *[2][text()='→']" replace: - T: "vektori" # phrase(the 'vector' reflects size and direction) - x: "*[1]" - name: default tag: modified-variable match: "count(*)=2 and not(@data-intent-property)" replace: - x: "*[1]" - x: "*[2]" - pause: short - name: default # handles single, double, etc., prime tag: [skip-super, say-super] match: "count(*)=2" replace: - x: "*[1]" - test: if: "name(.)='say-super'" then_test: if: "$Verbosity='Terse'" then: {T: "yli"} # phrase(this is a 'super' set of numbers) # FI: have to check the context else: {T: "yläindeksi"} # phrase(a 'superscript' number indicates raised to a power) - x: "*[2]" - pause: short - name: msubsup-skip-super # handles single, double, etc., prime tag: [skip-super, say-super] match: "count(*)=3" replace: - x: "*[1]" - test: if: "$Verbosity='Verbose'" then: {T: "alaindeksi"} # phrase(a 'subscript' may be used to indicate an index) else: {T: "ala"} # phrase(the result is 'sub' optimal) - x: "*[2]" - test: if: "DEBUG(not(IsNode(*[2],'leaf')))" then: - test: if: "$Verbosity='Verbose'" then: {T: "loppu alaindeksi"} # phrase(this is the 'end subscript' position) else: {T: "loppu ala"} # phrase(this is the 'end sub' position) - pause: short else_test: if: "*[2][self::m:mi]" # need a pause in "x sub k prime" so the prime is not associated with the 'k' then: [pause: short] - test: if: "name(.)='say-super'" then_test: if: "$Verbosity='Verbose'" then: {T: "yläindeksi"} # phrase(a 'superscript' number indicates raised to a power) else: {T: "yli"} # phrase(this is a 'super' set of numbers) # FI: does this mean "superset" or "superscript"? - x: "*[3]" - pause: short - name: sin tag: mi match: "text()='sin'" replace: - bookmark: "@id" - T: "sini" # phrase(the 'sine' of the angle) - name: cos tag: mi match: "text()='cos'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "kos"} # phrase('cos' is the abbreviation for cosine) else: {T: "kosini"} # phrase(find the 'cosine' in a right-angle triangle) - name: tan tag: mi match: "text()='tan' or text()='tg'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "tan"} # phrase(the 'tan' is the ratio of the opposite to the adjacent side of a right-angled triangle) else: {T: "tangentti"} # phrase(a 'tangent' is a straight line that touches a curve) - name: sec tag: mi match: "text()='sec'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "sek"} # phrase(to 'seek' a solution) else: {T: "sekantti"} # phrase(a 'secant' intersects a curve at two or more points) - name: csc tag: mi match: "text()='csc'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "kosekant"} # phrase(we will 'cosecant' a solution) else: {T: "kosekantti"} # phrase(the 'cosecant' is the reciprocal of the secant) - name: cot tag: mi match: "text()='cot'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "kotan"} # phrase(find the 'cotangent' in a right-angle triangle) else: {T: "kotangentti"} # phrase(the 'cotangent' is the reciprocal of the tangent) - name: sinh tag: mi match: "text()='sinh'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "sinh"} # phrase(the word 'sinch' is an abbreviation for hyperbolic sine) # FI: should listen to this else: {T: "hyperbolinen sini"} # phrase(the 'hyperbolic sine' is used in mathematics) - name: cosh tag: mi match: "text()='cosh'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "kosh"} # phrase('cosh' is an abbreviation of hyperbolic cosine) else: {T: "hyperbolinen kosini"} # phrase(the 'hyperbolic cosine' is a mathematical function) - name: tanh tag: mi match: "text()='tanh'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "tanh"} # phrase('tanch' is shorthand for hyperbolic tangent) # FI: have to listen to this else: {T: "hyperbolinen tangentti"} # phrase('hyperbolic tangent' is a mathematical function) - name: sech tag: mi match: "text()='sech'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "sekanth"} # phrase('sheck' is shorthand for hyperbolic secant) else: {T: "hyperbolinen sekantti"} # phrase('hyperbolic secant' is a mathematical function) - name: csch tag: mi match: "text()='csch'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "kosekanth"} # phrase('cosheck' is shorthand for hyperbolic cosecant) else: {T: "hyperbolinen kosekantti"} # phrase('hyperbolic cosecant' is a mathematical function) - name: coth tag: mi match: "text()='coth'" replace: - bookmark: "@id" - test: if: "$Verbosity='Terse'" then: {T: "kotanh"} # phrase('cotanch' is shorthand for hyperbolic cotangent) else: {T: "hyperbolinen kotangentti"} # phrase(the 'hyperbolic cotangent' is a mathematical function) - # handle both log and ln name: log tag: mrow variables: [{log_is_simple: "IsNode(*[3],'simple')"}] match: - "count(*)=3 and" - "*[1][self::m:mi][text()='log' or text()='lg' or text()='ln'] and" - "*[2][self::m:mo][text()='⁡']" replace: - bookmark: "*[1]/@id" - test: if: "$log_is_simple" then_test: - if: "*[1][text()='log']" then: [{T: "log"}] # phrase(the 'log' function is used in mathematics) - else_if: "*[1][text()='lg']" then_test: - if: "$Verbosity='Terse'" then: [{SPELL: "'lg'"}] else: [{T: "kymmenkantainen logaritmi"}] - else_if: "$Verbosity='Terse'" then: [{SPELL: "'ln'"}] else: [{T: "luonnollinen log"}] # phrase(the 'natural log' function is used in mathematics) else: # FI: not needed # - test: # if: "$Verbosity!='Terse' and not(log_is_simple)" # then: {T: ""} # phrase('the' square root of 25 equals 5) - test: - if: "*[1][text()='log']" then: [{T: "log"}] # phrase(the 'log' function is used in mathematics) - else_if: "*[1][text()='lg']" then: [{SPELL: "'lg'"}] # phrase(the 'log' function is used in mathematics) - else_if: "$Verbosity='Terse'" then: [{SPELL: "'ln'"}] else: [{T: "luonnollinen logaritmi"}] # phrase(the 'natural log' function is used in mathematics) # FI: not needed # - T: "" # phrase(5 is the square root 'of' 25) - pause: short - x: "*[3]" - name: log-base tag: log-base match: "not(@data-intent-property)" replace: - bookmark: "@id" - test: if: "$Verbosity!='Terse'" then: {T: ""} # phrase('the' square root of 25 equals 5) - T: "log kanta" # phrase(the 'log base' is often base 10) - x: "*[1]" - name: log-base-power tag: log-base-power match: "not(@data-intent-property)" replace: - bookmark: "@id" - test: if: "$Verbosity!='Terse'" then: {T: ""} # phrase('the' square root of 25 equals 5) - T: "log kanta" # phrase(the 'log base' is often base 10) - x: "*[1]" - pause: medium - test: - if: "*[2][text()=2]" then: [T: "toiseen"] - else_if: "*[2][text()=3]" then: [T: "kolmanteen"] else: # don't bother with special cases as this isn't likely to happen - T: "potenssiin" # phrase(x 'raised to the' second power) - x: "*[2]" # - T: "potenssi" # phrase(x raised to the second 'power') - pause: short - name: multi-line # that eliminates the need for the if: else_if: ... # IDEA: set a variable with the word to say for the row (e.g., RowLabel = Row/Case/Line/...) tag: [piecewise, system-of-equations, lines] match: "." variables: # Wikipedia has some tables where all the entire first column is empty (e.g., https://en.wikipedia.org/wiki/List_of_trigonometric_identities) - LineCountTry: "count(*/*[1][count(*)=1 and *[1][@data-added!='missing-content']])" - LineCount: "IfThenElse($LineCountTry=0, count(*/*[1]), $LineCountTry)" - IsColumnSilent: true() replace: - x: "$LineCount" - test: - if: "self::m:piecewise" then: - test: - if: "$LineCount != 1" then: [{T: "tapausta"}] # FI: plural, needs test else: [{T: "tapaus"}] # phrase(this is the first 'equation' of three equations) - else_if: "self::m:system-of-equations" then: - test: - if: "$LineCount != 1" then: [{T: "yhtälöä"}] # FI: plural, needs test else: [{T: "yhtälö"}] # phrase(this is the first 'equation' of three equations) else: - test: - if: "$LineCount != 1" then: [{T: "riviä"}] # FI: plural, needs test else: [{T: "rivi"}] # phrase(this is the first 'line' of three lines) # - test: # - if: "$LineCount != 1" # then: [{CT: "t"}] # plural - pause: short - x: "*" - name: default-multiline tag: [mtr, mlabeledtr] match: "parent::m:piecewise or parent::m:system-of-equations or parent::m:lines" replace: - test: if: "parent::m:system-of-equations and *[1][count(*)=1 and *[1][@data-added='missing-content']] and count(*/*[1][count(*)=1 and *[1][@data-added!='missing-content']]) != 0" then: - T: "seuraava rivi" else_test: if: "$LineCount != 1" then: - test: - if: "parent::m:piecewise" then: [{T: "tapaus"}] # phrase('case' 1 of 10 cases) - else_if: "parent::m:system-of-equations" then: [{T: "yhtälö"}] # phrase('equation' 1 of 10 equations) else: [{T: "rivi"}] # phrase('line 1 of 10 lines) - x: "count(preceding-sibling::*)+1" - test: if: .[self::m:mlabeledtr] then: - T: "merkinnällä" # phrase(the diagram is complete 'with label') - x: "*[1]/*" - pause: medium - test: if: .[self::m:mlabeledtr] then: [{x: "*[position()>1]"}] else: {x: "*"} - name: default-multiline tag: mtd match: "parent::*[parent::m:piecewise or parent::m:system-of-equations or parent::m:lines]" variables: [LongPause: "$SpeechStyle = 'ClearSpeak' and $ClearSpeak_MultiLinePausesBetweenColumns = 'Long'"] replace: - x: "*" - test: # short pause after each element; medium pause if last element in a row; long pause for last element in matrix unless ClearSpeak override - if: "count(following-sibling::*) > 0" then_test: if: "$LongPause" then: {pause: medium} else: {pause: short} - else_if: "count(../following-sibling::*) > 0" then_test: if: "$LongPause" then: {pause: long} else: {pause: medium} else: {pause: long} # Matrix/Determinant rules # matrix and determinant are the same other than "matrix"/"determinant" based on the bracketing chars # the pausing logic is pushed down to the # the rules either speak the s (to get "row n") or the s. "column n" spoken if $IsColumnSilent is false - name: 1x1-matrix tag: [matrix, determinant] variables: [{IsColumnSilent: true()}] match: "count(*)=1 and *[self::m:mtr][count(*) = 1]" replace: # - OT: "" # phrase('the' 1 by 1 matrix M) - T: "1 kertaa 1" # phrase(the '1 by 1' matrix) - test: if: "self::m:determinant" # just need to check the first bracket since we know it must be (, [, or | then: {T: "determinantti"} # phrase(the 2 by 2 'determinant')) else: {T: "matriisi"} # phrase(the 2 by 2 'matrix') # - T: "merkinnällä" # phrase(the 2 by 2 matrix 'with entry' x) - x: "*[1]/*" # simpler reading methods for smaller matrices if the entries are simple - name: 2-or-3x1-matrix tag: matrix variables: [{IsColumnSilent: true()}] match: - "$ClearSpeak_Matrix != 'SpeakColNum' and " # "simple" isn't used for this preference - "*[self::m:mtr][count(*) = 1] and " # one column - count(*)<=3 and # at least two rows - IsNode(*/*/*,'simple') # IsNode() returns true if all the nodes are simple replace: - T: "" # phrase('the' 2 by 2 matrix M) - x: count(*) - T: "kertaa 1 sarake" # phrase(the 2 'by 1 column' matrix) - test: if: "$ClearSpeak_Matrix = 'Vector' or $ClearSpeak_Matrix = 'EndVector'" then: {T: "vektori"} # phrase(the 2 by 2 'vector') else: {T: "matriisi"} # phrase(the 2 by 2 'matrix') - pause: long - x: "*/*" - test: if: "$ClearSpeak_Matrix = 'EndMatrix' or $ClearSpeak_Matrix = 'EndVector'" then: - T: "" # phrase('end' of matrix) - test: if: $ClearSpeak_Matrix = 'EndVector' then: {T: "loppu vektori"} # phrase(the 2 column 'end vector') else: {T: "loppu matriisi"} # phrase(the 2 by 2 'end matrix') - name: default-column-matrix tag: matrix variables: [{IsColumnSilent: true()}] match: "*[self::m:mtr][count(*) = 1]" replace: - T: "" # phrase('the' 2 by 2 matrix M) - x: "count(*)" - T: "kertaa 1 sarake" # phrase(the 2 'by 1 column' matrix) - test: if: "$ClearSpeak_Matrix = 'Vector' or $ClearSpeak_Matrix = 'EndVector'" then: {T: "vektori"} # phrase(the 2 column 'vector') else: {T: "matriisi"} # phrase(the 2 by 2 'matrix') - pause: long - x: "*" # select the rows (mtr) - test: if: "$ClearSpeak_Matrix = 'EndMatrix' or $ClearSpeak_Matrix = 'EndVector'" then: [{T: "loppu matriisi"}] # phrase(the 'end of matrix' has been reached) - name: 1x2-or-3-matrix tag: matrix variables: [{IsColumnSilent: "$SpeechStyle = 'SimpleSpeak' or ($SpeechStyle = 'ClearSpeak' and $ClearSpeak_Matrix != 'SpeakColNum')"}] match: - "$ClearSpeak_Matrix != 'SpeakColNum' and " # "simple" isn't used for this preference - count(*)=1 and # one row - count(*[1]/*)<=3 and # at least two cols - IsNode(*/*/*,'simple') # IsNode() returns true if all the nodes are simple replace: - T: "1 kertaa" # phrase('the 1 by' 2 matrix) - x: count(*/*) - T: "rivi" # phrase(the 1 by 4 'row' matrix) - test: if: "$ClearSpeak_Matrix = 'Vector' or $ClearSpeak_Matrix = 'EndVector'" then: {T: "vektori"} # phrase(the 1 by 2 row 'vector') # FI: what is the context? else: {T: "matriisi"} # phrase(the 1 by 2 'matrix') - pause: long - x: "*/*" - test: if: "$ClearSpeak_Matrix = 'EndMatrix' or $ClearSpeak_Matrix = 'EndVector'" then: - T: "" # phrase(the 'end' of matrix has been reached) # FI: maybe change logic? - test: if: $ClearSpeak_Matrix = 'EndMatrix' then: {T: "loppu matriisi"} # phrase(the 2 by 2 'matrix') else: {T: "loppu vektori"} # phrase(the 2 by 1 'vector') - name: default-row-matrix tag: matrix variables: [{IsColumnSilent: "$SpeechStyle = 'ClearSpeak' and $ClearSpeak_Matrix = 'SilentColNum'"}] match: "count(*)=1" # one row replace: - T: "1 kertaa" # phrase('the 1 by' 2 matrix) - x: "count(*/*)" - T: "rivi" # phrase(the 1 by 2 'row' matrix) - test: if: "$ClearSpeak_Matrix = 'Vector' or $ClearSpeak_Matrix = 'EndVector'" then: {T: "vektori"} # phrase(the 2 by 1 'vector') else: {T: "matriisi"} # phrase(the 2 by 2 'matrix') - pause: long - pause: medium - x: "*/*" # select the cols (mtd) - test: if: "$ClearSpeak_Matrix = 'EndMatrix' or $ClearSpeak_Matrix = 'EndVector'" then: - T: "loppu" # phrase(the 'end' of matrix has been reached) - test: if: $ClearSpeak_Matrix = 'EndMatrix' then: {T: "matriisi"} # phrase(the 2 by 2 'matrix') else: {T: "vektori"} # phrase(the 2 by 1 'vector') - name: simple-small-matrix tag: [matrix, determinant] match: - "$ClearSpeak_Matrix != 'SpeakColNum' and " # "simple" isn't used for this preference - (count(*)<=3 and count(*[1]/*)<=3) and # no bigger than a 3x3 matrix - IsNode(*/*/*,'simple') # IsNode() returns true if all the nodes are simple variables: [{IsColumnSilent: "$SpeechStyle = 'SimpleSpeak' or ($SpeechStyle = 'ClearSpeak' and $ClearSpeak_Matrix != 'SpeakColNum')"}] replace: - T: "" # phrase('the' 1 by 2 matrix M) - x: count(*) - T: "kertaa" # phrase(the 1 'by' 2 matrix) - x: count(*[self::m:mtr][1]/*) - test: if: "self::m:determinant" then: {T: "determinantti"} # phrase(the 2 by 2 'determinant') else: {T: "matriisi"} # phrase(the 2 by 2 'matrix') - pause: long - x: "*" - test: if: "$ClearSpeak_Matrix = 'EndMatrix' or $ClearSpeak_Matrix = 'EndVector'" then: - T: "" # phrase(the 'end' of matrix has been reached) - test: if: "self::m:determinant" then: {T: "loppu determinantti"} # phrase(the 2 by 2 'determinant') else: {T: "loppu matriisi"} # phrase(the 2 by 2 'matrix') - name: default-matrix tag: [matrix, determinant] variables: [{IsColumnSilent: "$SpeechStyle = 'ClearSpeak' and $ClearSpeak_Matrix = 'SilentColNum'"}] match: "not(@data-intent-property)" replace: - T: "" # phrase('the' 1 by 2 matrix M) - x: "count(*)" - T: "kertaa" # phrase(the 1 'by' 2 matrix) - x: "count(*[self::m:mtr][1]/*)" - test: if: "self::m:determinant" then: {T: "determinantti"} # phrase(the 2 by 2 'determinant') else: {T: "matriisi"} # phrase(the 2 by 2 'matrix') - pause: long - x: "*" - test: if: "$ClearSpeak_Matrix = 'EndMatrix' or $ClearSpeak_Matrix = 'EndVector'" then: - T: "loppu" # phrase(the 'end' of matrix has been reached) - test: if: "self::m:determinant" then: {T: "determinantti"} # phrase(the 2 by 2 'determinant') else: {T: "matriisi"} # phrase(the 2 by 2 'matrix's) - name: chemistry-msub tag: [chemical-formula] match: "*[1][text()='msub']" replace: - x: "*[2]" - test: if: "$Verbosity='Verbose'" then: [{T: "alaindeksi"}] # phrase(H 'subscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ala"}] # phrase(H 'sub' 2) - x: "*[3]" - name: chemistry-msup tag: [chemical-formula] match: "count(*)=3 and *[1][text()='msup']" replace: - x: "*[2]" - test: if: "$Verbosity='Verbose'" then: [{T: "yläindeksi"}] # phrase(H 'superscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ylä"}] # phrase(H 'super' 2) - x: "*[3]" - test: if: "following-sibling::*[1][text()='+' or text()='-']" # a little lazy -- assumes chemistry superscripts end with + or - then: [{pause: medium}] - # There currently is no way to do sub/super for n-ary number of args # Instead, we just deal with up to two prescripts and up to four postscripts (repeating blocks of similar code [UGLY!]) # This hopefully covers all reasonable cases... name: chemistry-scripts tag: [chemical-formula, chemical-nuclide] variables: # computing the number of postscripts is messy because of being optionally present -- we use "mod" to get the count right - Prescripts: "m:mprescripts/following-sibling::*" - NumChildren: "count(*)" # need to stash this since the count is wrong inside '*[...]' below - Postscripts: "*[position()>1 and position() < (last() + ($NumChildren mod 2) -count($Prescripts))]" match: . # should only be msubsup or mmultiscripts at this point replace: - test: if: "$Prescripts" # we have at least one pre sub/super then: # nuclide: speak the superscript first - test: if: "not($Prescripts[2][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "yläindeksi"}] # phrase(H 'superscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ylä"}] # phrase(H 'super' 2) - x: "$Prescripts[2]" - pause: "short" - test: if: "not($Prescripts[1][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "alaindeksi"}] # phrase(a 'subscript' may be used to indicate an index) else_test: if: "$Verbosity='Medium'" then: [{T: "ala"}] # phrase(here is a 'sub' total) - x: "$Prescripts[1]" - pause: "short" - test: if: "count($Prescripts) > 2" # can this happen for chemistry??? we allow for one *extra* pre sub/super pair then: - test: if: "not($Prescripts[4][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "yläindeksi"}] # phrase(H 'superscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ylä"}] # phrase(H 'super' 2) - x: "$Prescripts[4]" - pause: "short" - test: if: "not($Prescripts[3][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "alaindeksi"}] # phrase(H 'subscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ala"}] # phrase(H 'sub' 2) - x: "$Prescripts[3]" - pause: "short" - x: "*[1]" # base - test: if: "$Postscripts" then: - test: if: "not($Postscripts[1][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "alaindeksi"}] # phrase(phrase(H 'subscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ala"}] # phrase(phrase(H 'sub' 2) - x: "$Postscripts[1]" - pause: "short" - test: if: "not($Postscripts[2][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "yläindeksi"}] # phrase(H 'superscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ylä"}] # phrase(H 'super' 2) - x: "$Postscripts[2]" - pause: "short" - test: if: "count($Postscripts) > 2" then: - test: if: "not($Postscripts[3][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "alaindeksi"}] # phrase(H 'subscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ala"}] # phrase(H 'sub' 2) - x: "$Postscripts[3]" - pause: "short" - test: if: "not($Postscripts[4][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "yläindeksi"}] # phrase(H 'superscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ylä"}] # phrase(H 'super' 2) - x: "$Postscripts[4]" - pause: "short" - test: if: "count($Postscripts) > 4" then: - test: if: "not($Postscripts[5][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "alaindeksi"}] # phrase(H 'subscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ala"}] # phrase(H 'sub' 2) - x: "$Postscripts[5]" - pause: "short" - test: if: "not($Postscripts[6][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "yläindeksi"}] # phrase(H 'superscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ylä"}] # phrase(H 'super' 2) - x: "$Postscripts[6]" - pause: "short" - test: if: "count($Postscripts) > 6" then: - test: if: "not($Postscripts[7][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "alaindeksi"}] # phrase(H 'subscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ala"}] # phrase(H 'sub' 2) - x: "$Postscripts[7]" - pause: "short" - test: if: "not($Postscripts[8][self::m:none])" then: - test: if: "$Verbosity='Verbose'" then: [{T: "yläindeksi"}] # phrase(H 'superscript' 2) else_test: if: "$Verbosity='Medium'" then: [{T: "ylä"}] # phrase(H 'super' 2) - x: "$Postscripts[8]" - pause: "short" - test: if: "$Postscripts[last()][not(self::m:none)] and following-sibling::*[1][text()='+' or text()='-']" then: [{pause: medium}] - name: chemistry tag: chemical-equation match: "." replace: - x: "*" - name: chemical-element tag: chemical-element match: "." replace: - bookmark: "@id" - spell: text() - pause: short - name: chemical-state tag: chemical-state match: "count(*)=1" replace: - bookmark: "*[1]/@id" - test: - if: ".='s'" then: [{T: "kiinteä"}] # phrase(Boron is a 'solid' in its natural state) - else_if: ".='l'" then: [{T: "neste"}] # phrase(water is a 'liquid') - else_if: ".='g'" then: [{T: "kaasu"}] # phrase(hydrogen is a 'gas' ) else: [{T: "vesiliuoksessa"}] # phrase(an 'aqueous' solution is contained in water) - pause: short - name: chemical-formula-operator-bond tag: chemical-formula-operator match: "@data-chemical-bond" replace: # FIX: this might be better/more efficient if in unicode.yaml - bookmark: "@id" - test: - if: "text()='-' or text() = ':'" then: [{T: "yksinkertainen sidos"}] # phrase(a 'single bond' is formed when two atoms share one pair of electrons) - else_if: "text()='=' or text() = '∷'" then: [{T: "kaksinkertainen sidos"}] # phrase(a 'double bond' may occur when two atoms share two pairs of electrons) - else_if: "text()='≡'" then: [{T: "kolminkertainen sidos"}] # phrase(a 'triple bond' occurs when two atoms share three pairs of electrons) - else_if: "text()='≣'" then: [{T: "nelinkertainen sidos"}] # phrase(a 'quadruple bond' occurs when two atoms share four pairs of electrons) else: [{x: "text()"}] - name: chemical-formula-operator tag: chemical-formula-operator match: "." replace: x: "text()" - name: chemical-arrow-operator tag: chemical-arrow-operator match: "." replace: # FIX: this might be better/more efficient if in unicode.yaml - bookmark: "@id" - test: - if: "DEBUG(.)='→' or .='⟶'" then_test: if: "$Verbosity='Terse'" then: [t: "muodostaa"] # phrase(hydrogen and oxygen 'forms' water ) else: [t: "reagoi"] # phrase(hydrogen and oxygen 'reacts to form' water) - else_if: ".='⇌' or .='\u1f8d2'" then: [t: "on tasapainossa"] # phrase(a reactant 'is in equilibrium with' a product) - else_if: ".='\u1f8d4'" then: [t: "on tasapainoissa vasemmalle"] # phrase(the reactant 'is in equilibrium biased to the left with' the product) - else_if: ".='\u1f8d3'" then: [t: "on tasapainossa oikealle"] # phrase(the reactant 'is in equilibrium biased to the right with' the product) else: [x: "*"] - name: chemical-equation-operator tag: chemical-equation-operator match: "." replace: - bookmark: "@id" - x: "text()" - name: none tag: none match: "../../*[self::m:chemical-formula or self::m:chemical-nuclide]" replace: - T: "" # don't say anything - name: ignore-intent-wrapper tag: intent-wrapper match: "." replace: - x: "*"