---
-
name: simple-number-set
tag: mi
match: "string-length(text())=1 and translate(text(), 'ℂℕℚℝℤ', '')=''" replace:
- intent:
name: number-sets
children: [x: "text()"]
-
name: sup-number-set
tag: msup
match:
- "*[1][string-length(text())=1 and translate(., 'ℂℕℚℝℤ', '')=''] and"
- "*[2][string-length(text())=1 and (.='+' or .='-' or self::m:mn)]"
replace:
- intent:
name: number-sets
children:
- x: "*[1]"
- x: "*[2]"
-
name: real-part
tag: mi
match: "(.='Re' or .='re' or .='ℜ') and following-sibling::*[1][.='\u2061']" replace:
- intent:
name: real-part
children: []
-
name: imaginary-part
tag: mi
match: "(.='Im' or .='im' or .='ℑ') and following-sibling::*[1][.='\u2061']" replace:
- intent:
name: imaginary-part
children: []
-
name: roman_numeral
tag: [mi, mn, mtext]
match: "@data-number"
replace:
- intent:
name: mn
children: [x: "@data-number"]
-
name: positive-or-negative
tag: mrow
match: "count(*)=2 and *[1][self::m:mo][.='+' or .='-']"
variables:
- AtLeftEdge: "EdgeNode(., 'left', 'mtd')"
- AtLeftEdgeOfMTD: "name($AtLeftEdge) = 'mtd'"
- ContinuedColumn: "$TableProperty='lines' or $TableProperty='system-of-equations' or $TableProperty='piecewise'"
- InContinuedRow: "parent::m:mtd[parent::m:mtr[@data-intent-property[contains(., ':continued-row:')]]]"
- FirstColumn: "$AtLeftEdge/../*[1]=$AtLeftEdge" replace:
- test:
if: "$AtLeftEdgeOfMTD and $ContinuedColumn and (not($FirstColumn) or $InContinuedRow)"
then:
- intent:
xpath-name: "IfThenElse(*[1][self::m:mo][.='+'], 'plus', 'minus')"
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children: [x: "*[2]"]
else:
- intent:
xpath-name: "IfThenElse(*[1][self::m:mo][.='+'], 'plus', 'minus')"
attrs: "data-intent-property='concat(data-intent-property, \":prefix:\")'"
children: [x: "*[2]"]
-
name: interval
tag: mrow
match:
- "count(*)=3 and "
- "(*[1][.='(' or .='['] and *[3][.=')' or .=']']) and" - "(*[2][count(*)=3 and *[2][.=',']]) and" - "not(ancestor::*[IsBracketed(., '{', '}') or IsBracketed(., '[', ']') or IsBracketed(., '(', ')')]) and "
- "not(descendant::*[IsBracketed(., '{', '}') or IsBracketed(., '[', ']') or IsBracketed(., '(', ')')]) and "
- "("
- " not(IsBracketed(., '(', ')')) or " - " $ClearSpeak_Paren = 'Interval' or " - " *[2]/*[1][contains(., '∞')] or " - " *[2]/*[3][contains(., '∞')] or " - " preceding-sibling::*[1][self::m:mo and ( .='=' or IsInDefinition(., 'SubsetOperators') )] or " - " following-sibling::*[1][self::m:mo and ( .='=' or IsInDefinition(., 'SubsetOperators') )]" - ")"
replace:
- test:
- if: "*[1][.='('] and *[3][.=')']"
then:
- intent:
name: "open-interval"
children: [x: "*[2]/*[1]", x: "*[2]/*[3]"]
- else_if: "*[1][.='('] and *[3][.=']']"
then:
- intent:
name: "open-closed-interval"
children: [x: "*[2]/*[1]", x: "*[2]/*[3]"]
- else_if: "*[1][.='['] and *[3][.=']']"
then:
- intent:
name: "closed-interval"
children: [x: "*[2]/*[1]", x: "*[2]/*[3]"]
else:
- intent:
name: "closed-open-interval"
children: [x: "*[2]/*[1]", x: "*[2]/*[3]"]
-
name: binomial-frac
tag: mrow
match: "IsBracketed(., '(', ')') and *[2][self::m:mfrac][translate(@linethickness, 'abcdefghijklmnopqrstuvwxyz', '')=0]"
replace:
- intent:
name: binomial
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children:
- x: "*[2]/*[1]"
- x: "*[2]/*[2]"
-
name: binomial-mmultiscripts
tag: mmultiscripts
variables:
- Prescripts: "m:mprescripts/following-sibling::*"
- Postscripts: "m:mprescripts/preceding-sibling::*[position() < last()]"
match:
- "*[1][self::m:mi and .='C'] and"
- "count($Prescripts)=2 and ($Prescripts[1][self::m:none] or $Prescripts[2][self::m:none]) and "
- "count($Postscripts)=2 and $Postscripts[2][self::m:none]"
replace:
- intent:
name: binomial
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children:
- x: "IfThenElse(name($Prescripts[2])='none', $Prescripts[1], $Prescripts[2])"
- x: "$Postscripts[1]"
-
name: binomial-msub tag: msub
match:
- "*[1][self::m:mi and .='C'] and"
- "*[2][self::m:mrow and count(*)=3 and *[2][.=',']]"
replace:
- intent:
name: binomial
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children:
- x: "*[2]/*[1]"
- x: "*[2]/*[3]"
-
name: permutation-mmultiscripts
tag: mmultiscripts
variables:
- Prescripts: "m:mprescripts/following-sibling::*"
- Postscripts: "m:mprescripts/preceding-sibling::*[position() < last()]"
match:
- "*[1][self::m:mi and .='P'] and"
- "count($Prescripts)=2 and ($Prescripts[1][self::m:none] or $Prescripts[2][self::m:none]) and "
- "count($Postscripts)=2 and $Postscripts[2][self::m:none]"
replace:
- intent:
name: pochhammer
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children:
- test:
if: "$Prescripts[1][self::m:none]"
then: [x: "$Prescripts[2]"]
else: [x: "$Prescripts[1]"]
- x: "$Postscripts[1]"
-
name: permutation-msubsup
tag: msubsup
match:
- "*[1][self::m:mi and .='P']"
replace:
- intent:
name: pochhammer
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children:
- x: "*[3]"
- x: "*[2]"
-
name: evaluated-at-msub
tag: mrow
match: "count(*)=2 and *[2][self::m:msub and *[1][self::m:mo][.='|']]"
replace:
- intent:
name: "evaluate"
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children:
- x: "*[1]"
- x: "*[2]/*[2]"
-
name: evaluated-at-msubsup
tag: mrow
match: "count(*)=2 and *[2][self::m:msubsup and *[1][self::m:mo][.='|']]"
replace:
- intent:
name: "evaluate"
children:
- x: "*[1]"
- x: "*[2]/*[2]"
- x: "*[2]/*[3]"
-
name: bracketed-evaluated-at
tag: msubsup
match: "IsBracketed(*[1], '[', ']')"
replace:
- intent:
name: "evaluate"
children:
- x: "*[1]/*[1]"
- x: "*[2]"
- x: "*[3]"
-
name: absolute-value
tag: mrow
match: "count(*) = 3 and not(*[2][self::m:mtable]) and IsBracketed(., '|', '|')"
replace:
- intent:
name: "absolute-value"
attrs: "data-intent-property='concat(data-intent-property, \":function:\")'"
children: [x: "*[2]"]
-
name: default
tag: msqrt
match: "."
replace:
- intent:
name: "square-root"
attrs: "data-intent-property='concat(data-intent-property, \":function:\")'"
children: [x: "*[1]"]
-
name: sqrt
tag: mroot
match: "*[2][self::m:mn and .='2']"
replace:
- intent:
name: "square-root"
attrs: "data-intent-property='concat(data-intent-property, \":function:\")'"
children: [x: "*[1]"]
-
name: default
tag: mroot
match: "."
replace:
- intent:
name: "root"
children:
- x: "*[1]"
- x: "*[2]"
- name: log-with-base
tag: [msub, msubsup]
match: "*[1][self::m:mi and .='log']"
replace:
- test:
if: "self::m:msub"
then:
- intent:
name: "logarithm-with-base"
attrs: "data-intent-property='concat(data-intent-property, \":prefix\")'"
children: [x: "*[2]"] else:
- intent:
name: "power"
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children:
- intent:
name: "logarithm-with-base"
attrs: "data-intent-property='concat(data-intent-property, \":prefix:\")'"
children: [x: "*[2]"] - x: "*[3]"
-
name: bigop
tag: [msub, munder]
match: "IsInDefinition(*[1], 'LargeOperators') or contains(@data-intent-property, ':largeop:')"
replace:
- intent:
name: "large-op" children:
- x: "*[1]"
- x: "*[2]"
-
name: limit
tag: [msub, munder]
variables: [NoSpacesBase: "translate(*[1], ' \u00A0\u2004\u2005\u2006\u2007\u2008\u2009\u200A','')"] match: "*[1][$NoSpacesBase='lim' or $NoSpacesBase='limsup' or $NoSpacesBase='liminf']"
replace:
- intent:
xpath-name: "IfThenElse($NoSpacesBase='lim', 'limit', IfThenElse($NoSpacesBase='limsup', 'limit-sup', 'limit-inf'))"
attrs: "data-intent-property='concat(data-intent-property, \":prefix:\")'"
children: [x: "*[2]"]
- name: repeating-decimal
tag: mrow
match: "count(*)=3 and *[1][self::m:mn] and
*[2][.='\u2062'] and
*[3][self::m:mover][*[1][self::m:mn] and *[2][.='\u00AF']]"
replace:
- intent:
name: "repeating-decimal"
children:
- x: "*[1]"
- x: "*[3]/*[1]"
-
name: modified-var
tag: mover
match: "*[1][self::m:mi] and *[2][translate(., '\u0306\u030c.\u00A8\u02D9\u20DB\u20DC`^~¯_', '')='']"
replace:
- intent:
name: "modified-variable"
attrs: "data-intent-property='concat(data-intent-property, \":silent:\")'"
children:
- x: "*[1]"
- x: "*[2]"
-
name: vector
tag: mover
match: "*[1][self::m:mi] and *[2][.='→' or .='⇀']"
replace:
- intent:
name: "vector"
attrs: "data-intent-property='concat(data-intent-property, \":prefix:\")'"
children:
- x: "*[1]"
-
name: chemistry-mhchem-equilibrium-arrow
tag: mover
match:
- "*[1][substring(., 1, 1)='↽'] and"
- "*[2][substring(., string-length(), 1)='⇀']"
replace:
- intent:
name: "chemical-arrow-operator"
children:
- test:
if: "*[1][self::m:mrow]"
then_test:
if: "*[2][self::m:mrow]"
then: [t: "\u1f8d2"] else: [t: "\u1f8d4"] else: [t: "\u1f8d3"]
-
name: chemistry
tag: [msub, msup]
match: "@data-chem-formula"
replace:
- intent:
name: "chemical-formula"
children: - x: "name(.)"
- x: "*[1]"
- x: "*[2]"
-
name: chemistry-prescripts
tag: mmultiscripts
match: "@data-chem-formula"
replace:
- test:
- if: "count(*)=4 or count(*)=6"
then:
- intent:
name: "chemical-nuclide"
children:
- x: "*"
else: - intent:
name: "chemical-formula"
children:
- x: "*"
-
name: chemical-element
tag: [mi, mtext]
match: "@data-chem-element"
replace:
- intent:
name: "chemical-element"
children:
- x: "text()"
-
name: unit
tag: [mi, mtext]
match: "@class='MathML-unit' or contains(@data-intent-property, ':unit')"
replace:
- intent:
name: "unit"
attrs: "data-intent-property='\":unit:\"'" children:
- x: "text()"
- name: mtext-inference-unit
tag: [mtext, mi]
match: "not(@data-chem-element) and
(self::m:mtext or string-length(.) > 1 or @mathvariant='normal') and
(parent::*[1][self::m:mrow and count(*)=3 and *[2][.='\u2062'] and
*[1][self::m:mn or (self::m:mfrac and *[1][self::m:mn] and *[2][self::m:mn])]]) and
count(preceding-sibling::*) = 2 and
(DefinitionValue(., 'Speech', 'SIUnits') != '' or
DefinitionValue(., 'Speech', 'UnitsWithoutPrefixes') != '' or
DefinitionValue(., 'Speech', 'EnglishUnits') != '' or
(string-length(.) >= 3 and
substring(., 1, 2) = 'da' and
DefinitionValue(substring(., 3), 'Speech', 'SIUnits') != '') or
(string-length(.) >= 2 and
DefinitionValue(substring(., 1, 1), 'Speech', 'SIPrefixes') != '' and
DefinitionValue(substring(., 2), 'Speech', 'SIUnits') != ''))"
replace:
- intent:
name: "unit"
attrs: "data-intent-property='\":unit:\"'" children:
- x: "text()"
-
name: chemical-formula-op
tag: [mo]
match: "@data-chem-formula-op"
replace:
- intent:
name: "chemical-formula-operator"
children:
- x: "text()"
-
name: chemical-arrow-op
tag: [mo]
match: "@data-chem-equation-op and translate(., '→➔←⟶⟵⤻⇋⇌↿↾⇃⇂⥮⥯⇷⇸⤉⤈⥂⥄', '')=''"
replace:
- intent:
name: "chemical-arrow-operator"
children:
- x: "text()"
-
name: chemical-equation-op
tag: [mo]
match: "@data-chem-equation-op"
replace:
- intent:
name: "chemical-equation-operator"
children:
- x: "text()"
-
name: chemistry-concentration
tag: mrow
match: "ancestor-or-self::*[@data-chem-equation] and IsBracketed(., '[', ']')"
replace:
- intent:
name: "chemistry-concentration"
attrs: "data-intent-property='concat(data-intent-property, \":function:\")'"
children:
- x: "*[2]"
-
name: chemistry-state
tag: mrow
match:
- "(@data-chem-formula or @data-chem-equation) and"
- "IsBracketed(., '(', ')') and"
- "*[2][.='s' or .='l' or .='g' or .='aq']"
replace:
- intent:
name: "chemical-state"
children:
- x: "*[2]"
-
name: skip-super
tag: [msup, msubsup]
match: "*[last()][translate(., '′″‴⁗\"†‡°*', '')='' or .=\"'\"]" replace:
- intent:
name: "skip-super"
attrs: "data-intent-property='concat(data-intent-property, \":silent:\")'"
children: [x: "*"]
-
name: mo-super
tag: [msup, msubsup]
match: "*[last()][self::m:mo]"
replace:
- intent:
name: "say-super"
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children: [x: "*"]
-
name: function-inverse
tag: msup
match:
- "*[2][self::m:mrow][count(*)=2] and" - "*[2]/*[1][self::m:mo][.='-'] and" - "*[2]/*[2][self::m:mn][.=1] and" - "*[1][self::m:mi] and IsInDefinition(*[1], 'TrigFunctionNames') and" - "following-sibling::*[1][self::m:mo][.='\u2061']" replace:
- intent:
name: "inverse-function"
children:
- x: "*[1]"
-
name: bigop
tag: [msubsup, munderover]
match: "IsInDefinition(*[1], 'LargeOperators') or contains(@data-intent-property, ':largeop:')"
replace:
- intent:
name: "large-op" children:
- x: "*[1]"
- x: "*[2]"
- x: "*[3]"
-
name: set
tag: mrow
match: "IsBracketed(., '{', '}') and
(count(*)=2 or (count(*)=3 and IsNode(*[2], 'leaf')) or . != translate(., ',∈∉|:', ''))"
replace:
- intent:
name: "set"
children:
- test:
if: count(*) = 2
then: []
else: [x: "*[2]"]
-
name: default
tag: msub
match: "."
replace:
- intent:
name: "indexed-by"
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children:
- x: "*[1]"
- x: "*[2]"
-
name: default
tag: msup
match: "."
replace:
- intent:
name: "power"
attrs: "data-intent-property='IfThenElse(*[1][contains(@data-intent-property, \":unit:\")], \":unit:\", \"\")'"
children:
- x: "*[1]"
- x: "*[2]"
-
name: default
tag: msubsup
match: "."
replace:
- intent:
name: "power"
children:
- intent:
name: "indexed-by"
attrs: "data-intent-property='concat(data-intent-property, \":infix:\")'"
children:
- x: "*[1]"
- x: "*[2]"
- x: "*[3]"
-
name: default
tag: mfrac
match: "."
replace:
- intent:
name: "fraction"
attrs: "data-intent-property='IfThenElse(*[1][contains(@data-intent-property, \":unit:\")] and
DEBUG(*[2])[contains(@data-intent-property, \":unit:\")],
\":unit:\",
\"\")'"
children:
- x: "*[1]"
- x: "*[2]"
-
name: mtable-property-is-set
tag: mtable
variables: [TableProperty: "IfThenElse(contains(@data-intent-property, ':array:'), 'array',
IfThenElse(contains(@data-intent-property, ':matrix:'), 'matrix',
IfThenElse(contains(@data-intent-property, ':determinant:'), 'determinant',
IfThenElse(contains(@data-intent-property, ':piecewise:'), 'piecewise',
IfThenElse(contains(@data-intent-property, ':system-of-equations:'), 'system-of-equations',
IfThenElse(contains(@data-intent-property, ':lines:'), 'lines',
$TableProperty))))))"] match: "$TableProperty !=''"
replace:
- intent:
xpath-name: "$TableProperty"
children:
- x: "*"
-
name: "piecewise"
tag: mrow
match: "count(*)=2 and *[1][.='{'] and
*[2][self::m:mtable and not(
contains(@data-intent-property, ':array:') or
contains(@data-intent-property, ':matrix:') or
contains(@data-intent-property, ':determinant:') or
contains(@data-intent-property, 'system-of-equations:') or
contains(@data-intent-property, ':lines:') )
]"
replace:
- with:
variables: [TableProperty: "'piecewise'"]
replace: [x: "*[2]"]
-
name: matrix
tag: mrow
match:
- "count(*)=3 and (IsBracketed(., '(', ')') or IsBracketed(., '[', ']')) and
*[2][self::m:mtable and not(
contains(@data-intent-property, ':piecewise:') or
contains(@data-intent-property, ':matrix:') or
contains(@data-intent-property, ':determinant:') or
contains(@data-intent-property, 'system-of-equations:') or
contains(@data-intent-property, ':lines:') )
]"
replace:
- with:
variables: [TableProperty: "'matrix'"]
replace: [x: "*[2]"]
-
name: determinant
tag: mrow
match:
- "count(*)=3 and IsBracketed(., '|', '|') and
*[2][self::m:mtable and not(
contains(@data-intent-property, ':array:') or
contains(@data-intent-property, ':matrix:') or
contains(@data-intent-property, ':piecewise:') or
contains(@data-intent-property, 'system-of-equations:') or
contains(@data-intent-property, ':lines:') )
]"
replace:
- with:
variables: [TableProperty: "'determinant'"]
replace: [x: "*[2]"]
-
name: mtable-equations-property
tag: mtable
match: "count(*) > 0 and *[1][contains(translate(., '=≠<>≤≥≦≧', '='), '=')]"
replace:
- with:
variables:
- TableProperty: "'system-of-equations'"
replace:
- intent:
name: "system-of-equations"
children:
- x: "*"
-
name: mtable-lines-property
tag: mtable
match: "count(*) > 0 and not(descendant::*[self::m:mo and not(.='-' or .='+')])"
replace:
- with:
variables:
- TableProperty: "'lines'"
replace:
- intent:
name: "lines"
children:
- x: "*"
-
name: consolidate-labeled-mtd-entries
tag: [mlabeledtr, mtr]
match: "count(*) > 1 and
($TableProperty = 'piecewise' or $TableProperty = 'system-of-equations' or $TableProperty = 'lines') and
(self::m:mlabeledtr or *[contains(@intent, ':equation-label')])"
replace:
- intent:
name: "mlabeledtr"
children:
- x: "*[contains(@intent, ':equation-label')]"
- intent:
name: "mtd"
attrs: "id=*[not(contains(@intent, ':equation-label'))][1]/*[1]/@id"
children:
- intent:
name: "mrow"
attrs: "id=*[not(contains(@intent, ':equation-label'))][1]/*[1]/@id"
children: [x: "*[not(contains(@intent, ':equation-label'))]"]
-
name: mlabeledtr
tag: mtr
match: "count(*) > 1 and *[contains(@intent, ':equation-label')]"
replace:
- intent:
name: "mlabeledtr"
children:
- x: "*[contains(@intent, ':equation-label')]"
- x: "*[not(contains(@intent, ':equation-label'))]"
-
name: consolidate-mtd-entries
tag: mtr
match: "count(*) > 1 and
($TableProperty = 'piecewise' or $TableProperty = 'system-of-equations' or $TableProperty = 'lines')"
replace:
- intent:
name: "mtr"
attrs: "id='@id'"
children:
- intent:
name: "mtd"
attrs: "id='*[1]/@id'"
children:
- intent:
name: "mrow"
attrs: "id='*[2]/@id'"
children: [x: "*"]
-
name: mtd-to-mrow
tag: mtd
match: "($TableProperty = 'piecewise' or $TableProperty = 'system-of-equations' or $TableProperty = 'lines') and
not(contains(@data-intent-property, ':equation-label'))"
replace:
- test:
if: "@data-intent-property"
then:
- intent:
name: "mrow"
attrs: "id=@id data-intent-property=@data-intent-property"
children: [x: "*"]
else:
- x: "*"