Speech-Rule-Engine/speech-rule-engine

aria-label support (or similar)

Closed this issue · 15 comments

pkra commented

As an author, I want to express my voice in an expression. This can for example be done by adding aria-labels to MathML nodes.

It would be helpful if SRE could leverage such information (rather than drop it).

Where exactly would these aria-labels live? On each element?
Can you get me an example?

pkra commented

Where exactly would these aria-labels live? On each element?

Yes, on an element.

Can you get me an example?

Of course I have https://codepen.io/pkra/pen/xRBZjq in mind.

That should be doable in the future. I've started designing this annotation structure in the context of the Simons project, which should allow us to flexibly deal with additional information, both during semantic interpretation and afterwards. This type of info could go there, along with info we might get say from the DLMF, context, etc.

I think this feature will be very useful, especially for inline math with short math expressions/formulas.

My question is, what kind of authoring tool could be used to add these custom aria-labels? If a work is authored in Markdown and then converted to HTML using pandoc, I hope there is a practical way to add these custom labels.

pkra commented

I hope there is a practical way to add these custom labels.

That's primariliy an authoring issue which is not really what SRE focuses on -- it digests MathML and adding aria-labels is the author's job.

In an HTML environment, templating is one obvious way to do this (or I suppose web-components-like things). For TeX-like input, one could handle this on the macro-level to pass information along in the conversion process.

pkra commented

@zorkow asked for examples.

I think the main use cases are

  • working around bugs or limitations in SRE
  • working around bugs in original sources

For the former, a typical example would be from the first block equation in https://en.wikipedia.org/wiki/Determinant: |A|={\begin{vmatrix}a&b\\c&d\end{vmatrix}}=ad-bc.

SRE detects that the part corresponding to vmatrix as a determinant but does not (yet) deduce that |A| should similarly be a determinant. (Which of course may not be the case, e.g., |-1| = begin{vmatrix}...).

So adding an aria-label determinant of A to the mrow around the |A| would allow one to improve this.

When it's in the realm of what SRE can do (as is the case here) then it would be even better to be able to specify data-sre-type="matrix" data-sre-role="determinant" or some such thing. This might even allow arbitrary markup (rather than just MathML) to be fed into SRE or derivatives such as the light walker (e.g., from a template or a web component such as https://codepen.io/pkra/pen/MGdmQj).

As examples for fixing authoring mistakes go, two types come to mind that I encounter regularly in production. First, authors sometimes insist on peculiar preferences (e.g., using a flipped over root as a harpoon to indicate function restriction). Second, bugs in the production can affect author content (e.g., switching out characters to similarly looking characters, e.g., εϵ∈). It is sometimes more practical to adjust the accessible rendering rather than revising a production tool chain.

Anyway, I hope that helps a bit.

pkra commented

Here's something straight out of production: an author had a macro called \bbDelta producing something like \Delta\llap{\scriptstyleΔ}, i.e., it created a fake blackboard character. Of course there are no unicode points for blackboard bold Greek so it may be questionable to slap a label like 'blackboard bold upper Delta' on ti yet it also seems dubious to have two deltas in non-visual output.

pkra commented

Interesting use case from Alex Jordan on the mathjax user group, https://groups.google.com/forum/#!topic/mathjax-users/iom8l2Bj5Hg

Labeling a "blank" in e.g. 2 + \underline{\hspace{1em}} = 5.

Another example:
<math> <mover> <mi>AC</mi> <mo stretchy="true">↔</mo> </mover> </math>

This translates to "AC left right arrow" using Clearspeak; it would be nice to be able to call that a "line" rather than a "left right arrow." (Ideally I'd like this to read "line AC" but this suggestion would be a big improvement.)

pkra commented

@zorkow this was the issue I had in mind yesterday. In particular my comments at #157 (comment)

pkra commented

Related: #80 (alt attributes for mglyph)

pkra commented

Here's another random use case: $\rm\LaTeX$.

PR #411 adds this feature.
SRE now recognises attributes alt, aria-label and exact-speech for providing alternative speech. It will automatically get precedence as speech for the entire subtree the attribute annotates.

pkra commented

This is great -- thanks, Volker!

pkra commented

I created a mathjax v3 extension to allow authors to set this -- https://github.com/krautzource/mathjax-aria-label/