Skip to content

Error reading an expression #97

@CyrilleB79

Description

@CyrilleB79

Issue

On this example page, MathCAT cannot read the math expression in paragraph "E Equals MC Squared in Table".
Instead of reading it, it reports "Error in speaking math.".

The mathml is the following.

<math xmlns='http://www.w3.org/1998/Math/MathML'>
<mtable>
  <mlabeledtr id="e-is-m-c-square">
  	<mtd>
  	<mtext></mtext>
  	</mtd>
      <mrow>
       <mi>E</mi>
       <mo>=</mo>
       <mrow>
       <mtd>
        <mi>m</mi>
        <mo>⁢<!--INVISIBLE TIMES--></mo>
        <msup>
         <mi>c</mi>
         <mn>2</mn>
        </msup>
        </mtd></mrow>
     </mrow>
    
  </mlabeledtr>
</mtable>
</math>

Error logged

The following error is logged:

ERROR - mathPres.MathCAT.MathCAT.MathCAT.getSpeechForMathMl (14:43:22.802) - MainThread (20320):
Traceback (most recent call last):
  File "mathPres\MathCAT\MathCAT.pyc", line 385, in getSpeechForMathMl
OSError: Pattern match/replacement failure!
caused by: attempting replacement pattern: "default" for "math".
Replacement
[test: [  if: '"*"' then:[intent: name: math,  attrs=''>
      children: ["*"]] else:[t: " "]]
]
...due to matching the MathML
 <math id='M3g12hus-0' data-id-added='true'>
  <mtable id='M3g12hus-1' data-id-added='true'>
    <mlabeledtr id='e-is-m-c-square'>
      <mtd id='M3g12hus-2' data-id-added='true'>
        <mtext data-added='missing-content' data-width='0' data-empty-in-2D='true' id='M3g12hus-3' data-id-added='true'> </mtext>
      </mtd>
      <mrow id='M3g12hus-4' data-id-added='true'>
        <mi id='M3g12hus-5' data-id-added='true'>E</mi>
        <mo id='M3g12hus-6' data-id-added='true'>=</mo>
        <mtd id='M3g12hus-7' data-id-added='true'>
          <mrow data-changed='added' id='M3g12hus-8' data-id-added='true'>
            <mi id='M3g12hus-9' data-id-added='true'>m</mi>
            <mo id='M3g12hus-10' data-id-added='true'>&#x2062;</mo>
            <msup id='M3g12hus-11' data-id-added='true'>
              <mi id='M3g12hus-12' data-id-added='true'>c</mi>
              <mn id='M3g12hus-13' data-id-added='true'>2</mn>
            </msup>
          </mrow>
        </mtd>
      </mrow>
    </mlabeledtr>
  </mtable>
 </math>
 with the pattern
"."
The patterns are in \\?\C:\Program Files\NVDA\include\nvda-mathcat\assets\Rules\intent.yaml.

caused by: replacing inside 'intent'
caused by: attempting replacement pattern: "mtable-equations-property" for "mtable".
Replacement
[with:
      variables: [name: TableProperty="'system-of-equations'"],
      replace: [intent: name: system-of-equations,  attrs=''>
      children: ["*"]]]
...due to matching the MathML
 <mtable id='M3g12hus-1' data-id-added='true'>
  <mlabeledtr id='e-is-m-c-square'>
    <mtd id='M3g12hus-2' data-id-added='true'>
      <mtext data-added='missing-content' data-width='0' data-empty-in-2D='true' id='M3g12hus-3' data-id-added='true'> </mtext>
    </mtd>
    <mrow id='M3g12hus-4' data-id-added='true'>
      <mi id='M3g12hus-5' data-id-added='true'>E</mi>
      <mo id='M3g12hus-6' data-id-added='true'>=</mo>
      <mtd id='M3g12hus-7' data-id-added='true'>
        <mrow data-changed='added' id='M3g12hus-8' data-id-added='true'>
          <mi id='M3g12hus-9' data-id-added='true'>m</mi>
          <mo id='M3g12hus-10' data-id-added='true'>&#x2062;</mo>
          <msup id='M3g12hus-11' data-id-added='true'>
            <mi id='M3g12hus-12' data-id-added='true'>c</mi>
            <mn id='M3g12hus-13' data-id-added='true'>2</mn>
          </msup>
        </mrow>
      </mtd>
    </mrow>
  </mlabeledtr>
 </mtable>
 with the pattern
"count(*) > 0 and *[1][contains(translate(., '=≠<>≤≥≦≧', '='), '=')]"
The patterns are in \\?\C:\Program Files\NVDA\include\nvda-mathcat\assets\Rules\Intent\general.yaml.

caused by: replacing inside 'with'
caused by: replacing inside 'intent'
caused by: attempting replacement pattern: "consolidate-labeled-mtd-entries" for "mlabeledtr".
Replacement
[intent: name: mlabeledtr,  attrs=''>
      children: 
  - "*[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: ["*[not(contains(@intent, ':equation-label'))]"]]
]
...due to matching the MathML
 <mlabeledtr id='e-is-m-c-square'>
  <mtd id='M3g12hus-2' data-id-added='true'>
    <mtext data-added='missing-content' data-width='0' data-empty-in-2D='true' id='M3g12hus-3' data-id-added='true'> </mtext>
  </mtd>
  <mrow id='M3g12hus-4' data-id-added='true'>
    <mi id='M3g12hus-5' data-id-added='true'>E</mi>
    <mo id='M3g12hus-6' data-id-added='true'>=</mo>
    <mtd id='M3g12hus-7' data-id-added='true'>
      <mrow data-changed='added' id='M3g12hus-8' data-id-added='true'>
        <mi id='M3g12hus-9' data-id-added='true'>m</mi>
        <mo id='M3g12hus-10' data-id-added='true'>&#x2062;</mo>
        <msup id='M3g12hus-11' data-id-added='true'>
          <mi id='M3g12hus-12' data-id-added='true'>c</mi>
          <mn id='M3g12hus-13' data-id-added='true'>2</mn>
        </msup>
      </mrow>
    </mtd>
  </mrow>
 </mlabeledtr>
 with the pattern
"count(*) > 1 and ($TableProperty = 'piecewise' or $TableProperty = 'system-of-equations' or $TableProperty = 'lines') and (self::m:mlabeledtr or *[contains(@intent, ':equation-label')])"
The patterns are in \\?\C:\Program Files\NVDA\include\nvda-mathcat\assets\Rules\Intent\general.yaml.

caused by: replacing inside 'intent'
caused by: During replacement, no matching element found

MathCAT version

  • Reproduced in NVDA 2026.1beta7 (don't know which version is included in it).
  • Also reproduced with NVDA 2025.2 + MathCAT 0.7.5

Additional note

I do not know if such issues should be reported in NVDA's repo, in this one ore in another one. Please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions