Speech-Rule-Engine/speech-rule-engine

MathML-Unit doesn't respect aria-label

Opened this issue · 1 comments

When aria-label is used, normally the generated math is overridden (from #157). The following MathML results in "35 mickeys per hour" with SRE v4.0.2:

<math>
  <mn>35</mn>
  <mi aria-label="mickeys per hour">mph</mi>
</math>

When units are properly annotated with the MathML-Unit class, many units are helpfully converted to better speech (from #364). The following results in "35 miles per hour":

<math>
  <mn>35</mn>
  <mi class="MathML-Unit">mph</mi>
</math>

However, when combined I'd expect aria-label to trump everything as it is the get-out-of-jail-free card for speech generation, but it seems that the units win; the following MathML also results in "35 miles per hour":

<math>
  <mn>35</mn>
  <mi class="MathML-Unit" aria-label="mickeys per hour">mph</mi>
</math>

Am I missing something here, or misunderstanding the role of aria-label?

No, you're not missing anything. Just the rule for unit fired before the direct-speech rule.

When multiple rules are applicable, SRE computes a priority order heuristically, which ranked the unit rule higher.
I am now forcing the priority of the direct-speech rule to Infinity on the assumption that any user defined speech should have priority over whatever SRE wants to say.