Speech-Rule-Engine / speech-rule-engine

Generating speech descriptions for XML structures
https://zorkow.github.io/speech-rule-engine/
Apache License 2.0
73 stars 39 forks source link

Invisible times not rendered as speech; should it be? #738

Closed klobetime closed 8 months ago

klobetime commented 8 months ago

Using the math:

<math>
  <mi>x</mi>
  <mo>&CenterDot;</mo>
  <mi>y</mi>
</math>

results in the speech, "x times y" as expected.

However, this math:

<math>
  <mi>x</mi>
  <mo>&InvisibleTimes;</mo>
  <mi>y</mi>
</math>

results in "x y" rather than "x times y."

I agree that "x y" is an accurate representation of what is rendered, but it seems to me if I've gone to the trouble of authoring the invisible times in there it should be spoken? I could easily be talked out of this, but wanted to bring it up.

zorkow commented 8 months ago

It actually is rendered as speech. However, it depends on rule set and preference whether or not it is surfaced. For example, when you use the clearspeak rules with the MoreImpliedTimes preference, all elided multiplications will be spoken. For example simple clearspeak is

./bin/sre -d clearspeak

<math>
  <mi>x</mi>
  <mo>&InvisibleTimes;</mo>
  <mi>y</mi>
</math>

x y

whereas using the preference, you will get

./bin/sre -d clearspeak -s ImpliedTimes_MoreImpliedTimes

<math>
  <mi>x</mi>
  <mo>&InvisibleTimes;</mo>
  <mi>y</mi>
</math>

x times y

If you generate speech for all sub-expressions, invisible times will always be translated into speech. This has the effect that when you interactively explore the expression (e.g., in a system like MathJax), it will always be spoken as times. As example, below is the semantically enriched mathml with the data-semantic-speech attributes:

<math data-semantic-type="infixop" data-semantic-role="implicit" data-semantic-annotation="clearspeak:simple;clearspeak:unit;depth:1" data-semantic-id="3" data-semantic-children="0,2" data-semantic-content="1" data-semantic-speech="x y" xmlns="http://www.w3.org/1999/xhtml">
  <mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-annotation="clearspeak:simple;depth:2" data-semantic-id="0" data-semantic-parent="3" data-semantic-speech="x">x</mi>
  <mo data-semantic-type="operator" data-semantic-role="multiplication" data-semantic-id="1" data-semantic-parent="3" data-semantic-operator="infixop,⁢" data-semantic-speech="times">⁢</mo>
  <mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-annotation="clearspeak:simple;depth:2" data-semantic-id="2" data-semantic-parent="3" data-semantic-speech="y">y</mi>
</math>
klobetime commented 8 months ago

That makes a lot of sense. Thank you for the explanation!