Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intent: Comparison with SRE #421

Closed
physikerwelt opened this issue Aug 27, 2022 · 32 comments
Closed

Intent: Comparison with SRE #421

physikerwelt opened this issue Aug 27, 2022 · 32 comments
Labels
intent Issues involving the proposed "intent" attr

Comments

@physikerwelt
Copy link
Member

physikerwelt commented Aug 27, 2022

Goal: To check if the intent attribute is practical, I would like to investigate if we can map SRE-enriched MML to MathML with intent attributes. For Wikipedia, we currently use SRE to enrich MathML and plan to implement a native rendering method that supports intent attributes. Before we jump into the details I would like to investigate if we can compare the semantics in the current format and the new intent attribute.

Example: Currently, the input $x^n$ will be rendered as

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" alttext="x Superscript n">
   <semantics>
      <msup data-semantic-type="superscript" data-semantic-role="latinletter" data-semantic-id="2" data-semantic-children="0,1">
         <mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-annotation="clearspeak:simple" data-semantic-id="0" data-semantic-parent="2">x</mi>
         <mrow class="MJX-TeXAtom-ORD">
            <mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-annotation="clearspeak:simple" data-semantic-id="1" data-semantic-parent="2">n</mi>
         </mrow>
      </msup>
      <annotation encoding="application/x-tex">x^{n}</annotation>
   </semantics>
</math>

In the MathML spec draft we see

<msup intent="power($base,$exp)">
  <mi arg="base">x</mi>
  <mi arg="exp">n</mi>
</msup>

If we ignore the additional mrow, replace power with superscript and use the variable names from SRE we get

<msup intent="superscript($0,$1)">
  <mi arg="0">x</mi>
  <mi arg="1">n</mi>
</msup>

So one initial rule to transform SRE enrichment to intent is
if data-semantic-type="identifier" add arg html attribute with the value of data-semantic-id
if data-semantic-type="superscript" add intent html attribute with the value of power($data-semantic-chilren[0],$data-semantic-chilren[0])
This would almost work, except that we need to add some random but fixed NameStartChar to comply with the intent grammar. If we choose a our SRE-generated intent would read

<msup intent="power($a0,$a1)">
  <mi arg="a0">x</mi>
  <mi arg="a1">n</mi>
</msup>

Let's look at a more involved example. Currently, mathoid generates from the input $E=mc^2$ the following output

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" alttext="upper E equals m c squared">
   <semantics>
      <mrow data-semantic-type="relseq" data-semantic-role="equality" data-semantic-id="8" data-semantic-children="0,7" data-semantic-content="1">
         <mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-annotation="clearspeak:simple" data-semantic-id="0" data-semantic-parent="8">E</mi>
         <mo data-semantic-type="relation" data-semantic-role="equality" data-semantic-id="1" data-semantic-parent="8" data-semantic-operator="relseq,=">=</mo>
         <mrow data-semantic-type="infixop" data-semantic-role="implicit" data-semantic-annotation="clearspeak:unit" data-semantic-id="7" data-semantic-children="2,5" data-semantic-content="6" data-semantic-parent="8">
            <mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-annotation="clearspeak:simple" data-semantic-id="2" data-semantic-parent="7">m</mi>
            <mo data-semantic-type="operator" data-semantic-role="multiplication" data-semantic-id="6" data-semantic-parent="7" data-semantic-added="true" data-semantic-operator="infixop,⁢">⁢</mo>
            <msup data-semantic-type="superscript" data-semantic-role="latinletter" data-semantic-id="5" data-semantic-children="3,4" data-semantic-parent="7">
               <mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-annotation="clearspeak:simple" data-semantic-id="3" data-semantic-parent="5">c</mi>
               <mrow class="MJX-TeXAtom-ORD">
                  <mn data-semantic-type="number" data-semantic-role="integer" data-semantic-font="normal" data-semantic-annotation="clearspeak:simple" data-semantic-id="4" data-semantic-parent="5">2</mn>
               </mrow>
            </msup>
         </mrow>
      </mrow>
      <annotation encoding="application/x-tex">E=mc^{2}</annotation>
   </semantics>
</math>

after some days of coding this could become

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" alttext="upper E equals m c squared">
   <semantics>
      <mrow intent="equality($a0,$a7)">
         <mi arg="a0">E</mi>
         <mo>=</mo>
         <mrow arg="a7" intent="infixop($a2,$a5)">
            <mi arg="a2">m</mi>
            <mo>⁢</mo>
            <msup arg="a5" intent="power($a3,$a4)">
               <mi arg="a3">c</mi>
               <mrow class="MJX-TeXAtom-ORD">
                  <mn arg="a4">2</mn>
               </mrow>
            </msup>
         </mrow>
      </mrow>
      <annotation encoding="application/x-tex">E=mc^{2}</annotation>
   </semantics>
</math>

Is that really what we want? While the alttext "upper E equals m c squared" is biased towards English (and a few other languages) I still think this (current output) is more helpful for people that do not see in comparison to the intent enriched presentation tree. I don't really see how one could encode this information with intent and arg attributes in the presentation part of the MathML tree. Especially squared is something people would probably say, even though there is no 1:1 correspondence to the presentation tree.

Via some option tuning one can also generate deep speech annotations:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" alttext="upper E equals m c squared">
   <semantics>
      <mrow data-semantic-type="relseq" data-semantic-role="equality" data-semantic-id="8" data-semantic-children="0,7" data-semantic-content="1" data-semantic-speech="upper E equals m c squared">
         <mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-annotation="clearspeak:simple" data-semantic-id="0" data-semantic-parent="8" data-semantic-speech="upper E">E</mi>
         <mo data-semantic-type="relation" data-semantic-role="equality" data-semantic-id="1" data-semantic-parent="8" data-semantic-operator="relseq,=" data-semantic-speech="equals">=</mo>
         <mrow data-semantic-type="infixop" data-semantic-role="implicit" data-semantic-annotation="clearspeak:unit" data-semantic-id="7" data-semantic-children="2,5" data-semantic-content="6" data-semantic-parent="8" data-semantic-speech="m c squared">
            <mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-annotation="clearspeak:simple" data-semantic-id="2" data-semantic-parent="7" data-semantic-speech="m">m</mi>
            <mo data-semantic-type="operator" data-semantic-role="multiplication" data-semantic-id="6" data-semantic-parent="7" data-semantic-added="true" data-semantic-operator="infixop,⁢" data-semantic-speech="times">⁢</mo>
            <msup data-semantic-type="superscript" data-semantic-role="latinletter" data-semantic-id="5" data-semantic-children="3,4" data-semantic-parent="7" data-semantic-speech="c squared">
               <mi data-semantic-type="identifier" data-semantic-role="latinletter" data-semantic-font="italic" data-semantic-annotation="clearspeak:simple" data-semantic-id="3" data-semantic-parent="5" data-semantic-speech="c" data-semantic-prefix="Base">c</mi>
               <mrow class="MJX-TeXAtom-ORD">
                  <mn data-semantic-type="number" data-semantic-role="integer" data-semantic-font="normal" data-semantic-annotation="clearspeak:simple" data-semantic-id="4" data-semantic-parent="5" data-semantic-speech="2" data-semantic-prefix="Exponent">2</mn>
               </mrow>
            </msup>
         </mrow>
      </mrow>
      <annotation encoding="application/x-tex">E=mc^{2}</annotation>
   </semantics>
</math>
@davidcarlisle
Copy link
Collaborator

davidcarlisle commented Aug 27, 2022

I'm not sure I understand your workflow, but i think the target intent values can be improved/simplified

<mrow intent="equality($a0,$a7)"> OK,except current core intent list has "equal"
         <mi arg="a0">E</mi>
         <mo>=</mo>
         <mrow arg="a7" intent="infixop($a2,$a5)"> I don't think this intent is helping.
            <mi arg="a2">m</mi>
            <mo>⁢</mo>
            <msup arg="a5" intent="power($a3,$a4)">
               <mi arg="a3">c</mi>
               <mrow class="MJX-TeXAtom-ORD">This mrow could be dropped as it's just the mn
                  <mn arg="a4">2</mn>
               </mrow>
            </msup>
         </mrow>
      </mrow>

power($a3,$a4) as it is in core intent list with "squared" as a reading when $a4 is 2 , you may expect this is read as c-squared.

so I think you should get "E equals m c squared" from

<mrow intent="equal($a0,$a7)"> 
         <mi arg="a0">E</mi>
         <mo>=</mo>
         <mrow arg="a7" >
            <mi arg="a2">m</mi>
            <mo>⁢</mo>
            <msup intent="power($a3,$a4)">
               <mi arg="a3">c</mi>
               <mn arg="a4">2</mn>
            </msup>
         </mrow>
      </mrow>

@physikerwelt
Copy link
Member Author

I'm not sure I understand your workflow, but i think the target intent values can be improved/simplified

Me neither -- the workflow is not established yet. I am just thinking about how one can transition from the current format to intent without losing semantics.

         <mrow arg="a7" intent="infixop($a2,$a5)"> I don't think this intent is helping.

It will be hard to figure out what will be helping and what not algorithmically. For the SRE the infixop seems to be helpful. looking at the speech output for the respective subtree

         <mrow data-semantic-type="infixop" data-semantic-role="implicit" data-semantic-annotation="clearspeak:unit" data-semantic-id="7" data-semantic-children="2,5" data-semantic-content="6" data-semantic-parent="8" data-semantic-speech="m c squared">

power($a3,$a4) as it is in core intent list with "squared" as a reading when $a4 is 2 , you may expect this is read as c-squared.

so I think you should get "E equals m c squared" from

Thank you. This made me think of trying it out with

https://nsoiffer.github.io/MathCATDemo/

apparently, there are no intent attributes needed to generate

"E equals m c squared"

So for this example, what would expose in the final output would be

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block" alttext="E=mc^{2}">
  <semantics>
    <mrow>
      <mi>E</mi>
      <mo>=</mo>
      <mi>m</mi>
      <msup>
        <mi>c</mi>
        <mrow class="MJX-TeXAtom-ORD"><!-- This will be removed later:-) -->
          <mn>2</mn>
        </mrow>
      </msup>
    </mrow>
    <annotation encoding="application/x-tex">E=mc^{2}</annotation>
  </semantics>
</math>

And we would not need any intent attributes here due to intelligent defaults. As a next step, I will see if I discover differences in the speech output of SRE and MathCat to understand when intent values are helpful.

@dginev
Copy link
Contributor

dginev commented Sep 20, 2022

@physikerwelt could you elaborate on

I am just thinking about how one can transition from the current format to intent without losing semantics.

To my understanding, SRE can continue using any data-* attributes it uses already, for as long as they are useful to the project. There is no restriction to "only" hold the intent attribute.

What will be important if you want to use SRE with intent is that a native capability is implemented in SRE that can recognize input trees that have already been annotated with the "intent" attribute. And then using that value directly.

For example, if I provide the input MathML

<mi intent="indicator-function">𝟏</mi>

SRE would need to pass the "indicator-function" to the speech string (maybe with an optional internationalization step), rather than run its own analysis to guess what 𝟏 meant.

But if I only provide <mi>𝟏</mi>, running the SRE analysis and speech generation as it stands today would be just the right thing to do.

In both cases, to my understanding SRE, as well as any other AT tool, should be welcome to deposit as many data-* attributes as convenient.

@physikerwelt
Copy link
Member Author

@dginev thank you for the clarification. It will, however, be hard to generate test cases, as there is no MathML with intent. For example, in Wikipedia, we only have TeX, and the possibility for semantic annotations such as https://en.wikipedia.org/w/index.php?title=Special:MathWikibase&qid=Q35875 I was hoping that one could generate the intent from these sources.

For example, I just annotated the definition for indicator function in Wikipedia. Now I would find a method that amends

<math display="block" xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \mathbf {1} _{A}(x):={\begin{cases}1~&amp;{\text{ if }}~x\in A~,\\0~&amp;{\text{ if }}~x\notin A~.\end{cases}}}">
  <semantics>
    <mrow class="MJX-TeXAtom-ORD">
      <mstyle scriptlevel="0" displaystyle="true">
        <msub>
          <mrow class="MJX-TeXAtom-ORD">
            <mn mathvariant="bold">1</mn>
          </mrow>
          <mrow class="MJX-TeXAtom-ORD">
            <mi>A</mi>
          </mrow>
        </msub>
        <mo stretchy="false">(</mo>
        <mi>x</mi>
        <mo stretchy="false">)</mo>
        <mo>:=</mo>
        <mrow class="MJX-TeXAtom-ORD">
          <mrow>
            <mo>{</mo>
            <mtable columnalign="left left" rowspacing=".2em" columnspacing="1em" displaystyle="false">
              <mtr>
                <mtd>
                  <mn>1</mn>
                  <mtext>&nbsp;</mtext>
                </mtd>
                <mtd>
                  <mrow class="MJX-TeXAtom-ORD">
                    <mtext>&nbsp;if&nbsp;</mtext>
                  </mrow>
                  <mtext>&nbsp;</mtext>
                  <mi>x</mi>
                  <mo>∈<!----></mo>
                  <mi>A</mi>
                  <mtext>&nbsp;</mtext>
                  <mo>,</mo>
                </mtd>
              </mtr>
              <mtr>
                <mtd>
                  <mn>0</mn>
                  <mtext>&nbsp;</mtext>
                </mtd>
                <mtd>
                  <mrow class="MJX-TeXAtom-ORD">
                    <mtext>&nbsp;if&nbsp;</mtext>
                  </mrow>
                  <mtext>&nbsp;</mtext>
                  <mi>x</mi>
                  <mo>∉<!----></mo>
                  <mi>A</mi>
                  <mtext>&nbsp;</mtext>
                  <mo>.</mo>
                </mtd>
              </mtr>
            </mtable>
            <mo fence="true" stretchy="true" symmetric="true"></mo>
          </mrow>
        </mrow>
      </mstyle>
    </mrow>
    <annotation encoding="application/x-tex">{\displaystyle \mathbf {1} _{A}(x):={\begin{cases}1~&amp;{\text{ if }}~x\in A~,\\0~&amp;{\text{ if }}~x\notin A~.\end{cases}}}</annotation>
  </semantics>
</math>

with the intents that might be derived from the special page.

@dginev
Copy link
Contributor

dginev commented Sep 20, 2022

It will, however, be hard to generate test cases, as there is no MathML with intent

This is indeed a very central problem for MathML Intent, not just for this issue.

Without a solid authoring workflow, and existing tools that support that authoring soon, the spec will be a "wish" more than anything. I think we should have at least a latexml capability and a mathjax extension that can emit "intent" attributes from some well-chosen LaTeX macro dialect.

I don't know which tool is currently used to generate MathML for wikipedia (I remember you wanted to work on a new alternative?), but having that emit "intent" from a couple of new macros will also go a long way towards a real workflow.

I had briefly brainstormed a sample idea of what such TeX authoring may look like at this comment. But we need an actual solid implementation, maybe even a CTAN package with a fixed name that various conversion tools could point to, the way e.g. mathjax has a named extension for "amscd" and latexml has a named binding for "amscd.sty.ltxml", both of which target the same amscd.sty on CTAN.

@physikerwelt
Copy link
Member Author

This is indeed a very central problem for MathML Intent, not just for this issue.

Ok. While this is not the answer, I wanted to hear it shows that I still do not understand the intent attribute. Reading the feedback from the TPAC meeting indicates that I am not the only person. Thus I think it would not be a waste of time if I understand why we use an attribute rather than encoding intent hints using content MathML to be able to communicate this to others.

Without a solid authoring workflow, and existing tools that support that authoring soon, the spec will be a "wish" more than anything. I think we should have at least a latexml capability and a mathjax extension that can emit "intent" attributes from some well-chosen LaTeX macro dialect.

I don't know which tool is currently used to generate MathML for wikipedia (I remember you wanted to work on a new alternative?), but having that emit "intent" from a couple of new macros will also go a long way towards a real workflow.

@AndreG-P @Hyper-Node and I are working on a native PHP implementation. We will thus be able to generate anything. However, we are following a strictly test-driven development cycle. With the TDD approach, we could generate valid (strict) content MathML, as well as valid HTML attributes. In addition, it seems hard but doable to implement a checking software that uses intent grammar and checks if an intent attribute is valid based on the grammar rules. However, if we develop an intent grammar checker, we might introduce bugs in it. Thus it would be great to have the opportunity to cross-validate this with other implementations. However, before investing here, it would be great to understand what the benefits of these very complicated attributes are. To me, it seems that either the data-* attributes from SRE as well as content MathML are much closer to today's data structures supported by browsers.

I had briefly brainstormed a sample idea of what such TeX authoring may look like at this comment. But we need an actual solid implementation, maybe even a CTAN package with a fixed name that various conversion tools could point to, the way e.g. mathjax has a named extension for "amscd" and latexml has a named binding for "amscd.sty.ltxml", both of which target the same amscd.sty on CTAN.

I would like to step one step back and understand what we need to capture before discussing the encoding. In the codemeta project, we use the term cross-walks to express the ability to translate from one encoding to another. Maybe we can start with and end-to-end analysis of the example of indicator-function you provided above.

Without any intent information mathoid (SRE) currently generates the following speech string:

bold 1 Subscript upper A Baseline left parenthesis x right parenthesis colon equals StartLayout Enlarged left brace 1st Row 1st Column 1 2nd Column if x element of upper A comma 2nd Row 1st Column 0 2nd Column if x not an element of upper A period EndLayout

whereas mathcat generates

bold one sub A times x :=; 2 cases, case 1; 1 , if x is a member of A , comma; case 2; 0 , if x, is not a member of A ; point;

With my current annotation in Wikidata one can infer that bold one sub A or bold 1 Subscript upper A Baseline means

indicator function and can be explained as a function that returns 1 if an element is present in a specified subset and 0 if absent; naturally isomorphic with a set's subsets

from line 142 in the open-intent table one can derive from column c that it is an indexed function. This information can also be exported to wikidata as the links to the wikidata items are already implicitly in the table via the wikipedia links. In this particular example, it will be difficult, however since the indicator function is only in column F as an alternative, but let's ignore this detail for now.

With this information, mathcat should now be able to figure out that times are incorrect. However, what should SRE generate in that case? What has been generated does not seem wrong (just a bit more verbose).

To come back to the title of the issue...
SRE seems also be developed with extensive test cases

If we wanted that SRE picks up semantics from Wikipedia we would, regardless of the format, be able to specify test cases with tuples of MathML input and expected speech output.

@dginev
Copy link
Contributor

dginev commented Sep 20, 2022

understand why we use an attribute rather than encoding intent hints using content MathML

Well, I don't have great news here either - Content MathML has an even worse authoring problem than intent, when it comes to informal mathematical documents written by human authors.

One of the excellent design choices in intent is that it allows "progressive remediation", via allowing "partial annotation" -- you can have a formula with 200 token elements and only annotate 1 of those elements with "intent".

To create Content MathML for the same expression you would need to map each of the 200 tokens to some Content equivalent. Authoring that is an even greater challenge (again, for informal mathematical documents, such as the ones on arXiv and wikipedia).

@physikerwelt
Copy link
Member Author

To create Content MathML for the same expression you would need to map each of the 200 tokens to some Content equivalent. Authoring that is an even greater challenge (again, for informal mathematical documents, such as the ones on arXiv and wikipedia).

Ok. I was not aware of that. I assumed one could use semantics elements to group presentation and content together. Why is that not possible?

semantics = element semantics {semantics.attributes,
MathExpression,
(annotation|annotation-xml)*}

@dginev
Copy link
Contributor

dginev commented Sep 20, 2022

from line 142 in the open-intent table one can derive from column c that it is an indexed function.

Let me mention that when that column was populated with information, I did not aim at creating a grammar rule set. It was mostly to allow easy grouping in pivot tables, so that we can get a human-friendly overview of the different kinds of notations ("this view shows infix operators", "this view shows all indexed functions" etc). I think Paul also had a demo using that kind of sorting capability.

I think automatically inferring intent is a much harder task than consulting a list of notations. There is context, both external and internal to the expression, and there is always a chance of cascading failures triggered by unknown notations.

The main added benefit of the intent attribute, and the lists, should be that when an authoring tool creates MathML with "intent" set, the ATs will use that attribute value to create more conceptual/natural speech strings.


Ok. I was not aware of that. I assumed one could use semantics elements to group presentation and content together. Why is that not possible?

I remember it being discussed during a meeting, and the group had wide consensus at the time that the ergonomics of fine-grained <semantics> elements is too verbose/heavy to be acceptable. There was also a position put forward that certain publishers of existing MathML have workflows where they would prefer not modifying the presentation tree elements, while being OK with modifying their attributes. That point was brought up on a few occasions when I suggested we could recommend additional <mrow> wrappers, and the group clearly established we are not able or willing to require such changes. So I assume new <semantics> wrappers will have a similar consideration.

@dginev
Copy link
Contributor

dginev commented Sep 20, 2022

Oh, and a question. For the feature you describe here:

indicator function and can be explained as "a function that returns 1 if an element is present in a specified subset and 0 if absent; naturally isomorphic with a set's subsets"

Is it accurate to state that neither SRE, nor Content MathML currently have a mechanism to carry that "explanation"/"description" ?

This is the kind of auxiliary information that seems to be the target of the aria-describedby or aria-details attributes from ARIA, when in regular HTML.

We also currently don't have a place to add such information in intent. So it would need to be a custom (i.e. non-standard, platform-specific) wikidata/wikipedia feature, unless we introduce some new MathML markup for it.

@physikerwelt
Copy link
Member Author

physikerwelt commented Sep 22, 2022

Let me mention that when that column was populated with information, I did not aim at creating a grammar rule set.

Ok. So one needs to have something like

<mi intent="indicator-function($a1)">𝟏</mi>

to give MathCat a chance to understand that this is not times, correct?

I remember it being discussed during a meeting, and the group had wide consensus at the time that the ergonomics of fine-grained <semantics> elements is too verbose/heavy to be acceptable. There was also a position put forward that certain publishers of existing MathML have workflows where they would prefer not modifying the presentation tree elements, while being OK with modifying their attributes. That point was brought up on a few occasions when I suggested we could recommend additional <mrow> wrappers, and the group clearly established we are not able or willing to require such changes. So I assume new <semantics> wrappers will have a similar consideration.

This does not seem convincing to me. Adding a new attribute seems much more overhead than using existing elements. I think if the MathML WG really intends to add a new attribute, we must have a better answer to the question. In particular, for Mathoid I think it would be more reasonable to add very few shallow content MathML elements and invest time to make a pull request for SRE to be able to improve the semantics based on the content MathML annotation.

@physikerwelt
Copy link
Member Author

This is the kind of auxiliary information that seems to be the target of the aria-describedby or aria-details attributes from ARIA, when in regular HTML.

I think this is good enough. I hope there is a way to provide this information only if it is requested. Putting all these descriptions in the DOM would add too much data volume.

@dginev
Copy link
Contributor

dginev commented Sep 22, 2022

You should consider participating more in prototyping the <semantics> approach if you are a proponent of it Moritz, and I suspect you will have to change some minds in the group to get traction at this point (mine included).

For applying an indicator function, the intent syntax would be:

<mrow intent="$idfun($set,$element)">
  <msub>
    <mi arg="idfun" intent="indicator-function">𝟏</mi>
    <mi arg="set">A</mi>
  </msub>
  <mo>(</mo>
  <mi arg="element">x</mi>
  <mo>)</mo>
</mrow>

and a hypothetical alternative via Content MathML would be:

<semantics>
  <mrow>
    <msub>
      <mi>𝟏</mi>
      <mi>A</mi>
    </msub>
    <mo>(</mo>
    <mi>x</mi>
    <mo>)</mo>
  </mrow>
  <annotation-xml encoding="MathML-Content">
    <apply>
      <csymbol cd="intent-open">indicator-function</csymbol>
      <ci>A</ci>
      <ci>x</ci>
    </apply>
  </annotation-xml>
</semantics>

That tree gets more verbose if we also include the id/xref mechanism for cross-referencing the individual pieces (so that AT knows it was indeed the bold 1 that was presenting the indicator-function).

see my follow-up comment for a slightly larger example.


As to ARIA, their group resolved to recommend to us to invent in MathML itself any potential mechanisms for accessibility that we may need, so that we capture the types of needs specific to math syntax. That conversation happened in ARIA #1723, you're welcome to review it.

I think for now we have accepted their guidance in that regard. But if we do not provide any markup that matches aria-describedby and aria-details in MathML 4, maybe we can recommend using them as-is.

@NSoiffer
Copy link
Contributor

Just a reminder why aria-label isn't used: aria-label affects the braille, but because math has a separate braille code from text, it would mean the braille generated would be wrong without a change to the definition of aria-label. There is a new aria-braillelabel attribute that can be used to override aria-label, but since you can't know what braille math code the reader wants, authoring tools can't make use of it.

There are a few other negatives of aria-label, but the first one is a showstopper.

I should note that AFAIK, aria-description does not have these problems and so could be used.

@clapierre
Copy link

Its important to point out that both aria-braillelabel and aria-description are new to ARIA 1.3 and are not yet in the specification existing ARIA 1.2 Specification. Hopefully ARIA 1.3 becomes a specification prior to the new MathML specification is released.

@physikerwelt
Copy link
Member Author

You should consider participating more in prototyping the <semantics> approach if you are a proponent of it Moritz, and I suspect you will have to change some minds in the group to get traction at this point (mine included).

The hypothetical content MathML looks valid to me according to the current MathML 3 spec and only slightly more verbose to one or the other verbosity metric. So I would really appreciate, if we could just allow this as a valid intent encoding.

An even less verbose notation is LaTeX which brings us back to what we see in a typical HTML source today. Moreover, the DLMF/DRMF projects are good staring points to put more semantics with minimal typing into LaTeX. If verbosity is our goal we should just allow MathML with only LaTeX annotations. This is similar to what TEI does.

Implementing validation for the proposed intent grammar which somehow breaks the canonical XML structure seems a nightmare to me. Putting a grammar inside an attribute seems to me like developing against the XML framework. This is my personal viewpoint. When others want to use the attribute this is fine, I just don't see myself implementing this, yet.

@davidcarlisle
Copy link
Collaborator

@physikerwelt replying to your comments out of order

Putting a grammar inside an attribute seems to me like developing against the XML framework.

This seems to be the fundamental objection, that intent is structurally "wrong" but I don't see that at all, there is a long history of embedding small grammars in sgml/xml attributes, notably XSL with xpath attributes, SVG with path syntax, html with css in style and more generally HTML(5) microdata/microformats for specifying mini-languages embedded in attributes. intent is rather close to microdata itemprop although having the inline function syntax gives extra flexibility which seems to be required for mathematics where more structures are required.

Looking at @dginev's intent v Content comparison in #421 (comment) Content is shown in a good light. In practice you also want to be able to navigate into the sub terms while maintaining the association. You can do this in theory by cross referencing id's as shown in the MathmL3 spec example
https://www.w3.org/TR/2014/REC-MathML3-20140410/chapter5.html#mixing.cr

But that markup is very fragile especially in any context where the mathml is source and needs to be edited (as opposed to simply being re-generated very time) . Also as the ids have document scope having so many ids in all Mathml makes re-use difficult. This was really the original motivation for intent: to embed the annotation in the presentation tree so that it was available at all levels of navigation, and to make something more amenable to human editing of existing mathml to improve the annotations just when needed.

That said, we don't have many tools generating intent, and even fewer using it, and browsers don't currently pass it to AT at all.
We only just posted the first public working draft of MathML4, and especially intent is still visibly in "first working draft" state, so comments are not unwelcome even if they are along the lines of "this is all wrong"... For the next draft of MathML4 we hope to have more intent examples and more text describing the use cases they are trying to solve. I'd encorage you, as these evolve, to show equivalent markup using Content MathML. Perhaps you have a more managable idiom than we came up with previously. It may yet prove necessary to move to an element rather than attribute syntax, or even if not, we may want to formalise a mapping from intent to such a markup, for those systems already handling that.

@polx
Copy link

polx commented Sep 24, 2022

It is cool that we come to the bone of the issue, a bone that @physikerwelt long bragged about.

I would like to suggest that we propose BOTH parallel markup and attributes, as alternative encodings of intents.

That is, I would like to suggest to introduce a small statement about an annotation element that would do the same job as the intent attribute. This would allow for richer markup for those who want to do so (as it was mentioned us in the i18n session).

I know for sure, however, that general utility is low, just as is parallel markup: desirable but rarely done.

@davidcarlisle
Copy link
Collaborator

@polx the generic mapping

<foo abc="xyz">...</foo>

to

<semantics>
  <foo>...</foo>
  <annotation name="abc">xyz</annotation>
</semantcs>

Is already used in the content-to-strict transformation to map any attributes (other, class, ...) not allowed in strict-content/openmath.

Having made such a mapping for intent you could of course change <annotation to <annotation-xml and use a structured annotation if there was no requirement to restrict to annotations compatible with attribute syntax.

@physikerwelt
Copy link
Member Author

I think development the generation and consumption of attribute values new on the complexity level of x-path for production use is nothing one can do on a voluntary basis in an reasonable amount of time. I don't see myself editing intent attributes with an editor as I would probably become frustrated about my own typos, missing or duplicated arg values and so on. It would probably be helpful to understand if there are people willing to edit anything else than LaTeX. Currently in my echo chamber I have the feeling that the workflow starts from LaTeX and if anything is wrong the LaTeX is changed and MathML is regenerated. If this is the workflow, verbosity of the generated MathML source code is not the most pressing problem. According to my knowledge the backwards translation from MathML to LaTeX has not been fully developed. So I think bootstrapping intent editing for MathML generated from LaTeX is not a low hanging fruit even if we had an intent package on ctan.
My experience from the prototype of a visual content MathML editor is that it is a huge challenge to preserve information from content MathML if the presentation gets changed. With internet this would be still a challenge but I believe it would be possible to benefit from the original intent annotations after the presentation was changed.

However editing MathML is to my mind of lower priority than getting tools to consume intent and generate better speech output in comparison to the output without intent.

I see basically two strategies, wait for someone to implement attribute based intent generation and verification tools or to abuse content MathML to encode intent now.

@davidfarmer
Copy link
Contributor

I see it the same way: for more than 99% of authors, all that will happen is they
write in their preferred authoring source format (maybe some modified version
of LaTeX, maybe some menu-driven system, maybe something else).

The authored source is converted to MathML with intent (and maybe also 'isa').
There is a way for them to check if the MathML output has correct intent.
If it doesn't, then the source is modified and the conversion happens again.

If the author cannot get the correct MathML+intent, they will view that as
a defect in the authoring system. It will not occur to them that modifying the
MathML is possible or desirable.

Nobody will edit the MathML.

Correction: 99.9% of the people creating MathML+intent will not edit the MathML.

Let's not have the other 0.1% have an outsize voice in the decisions we are making.

@dginev
Copy link
Contributor

dginev commented Sep 25, 2022

@davidcarlisle wrote:

Looking at @dginev's intent v Content comparison in #421 (comment) Content is shown in a good light. In practice you also want to be able to navigate into the sub terms while maintaining the association.

That is a fair comment, I should also offer a counter-example.

I hand-crafted the smallest example I could think of that can exemplify the partial annotation approach, notably relying on the id/xref technique, but also requiring use of the <share> element. I am not sure if share can point to presentation elements, so I also auto-wrapped the targets with an extra <semantics> element to be certain the example is valid per MathML 3. I hope I got it right.

The key new snippet is:

    <apply>
      <csymbol cd="intent-open">multinomial-coeffficient</csymbol>
      <share href="id-for-top"></share>
      <share href="id-for-bottom"></share>
    </apply>

Find the full example with more comments at this gist:
https://gist.github.com/dginev/ee8e771b8196a21f76b27af9f1ed3368

The attribute variant is 25 lines, single tree.
The mixed tree variant is 65 lines, with 4 localized content trees annotating a single presentation tree.

Admin note: continued work on this "mixed tree" alternative should probably get a dedicated new issue and discussion. I hope bootstrapping these examples gets various participants here (de)motivated enough to do some prototyping.

@davidcarlisle davidcarlisle added the intent Issues involving the proposed "intent" attr label Sep 30, 2022
@brucemiller
Copy link
Contributor

brucemiller commented Oct 11, 2022 via email

@davidfarmer
Copy link
Contributor

davidfarmer commented Oct 11, 2022 via email

@davidfarmer
Copy link
Contributor

davidfarmer commented Oct 11, 2022 via email

@davidcarlisle
Copy link
Collaborator

Can this be closed @physikerwelt ?

@physikerwelt
Copy link
Member Author

I would keep it open until we have agreed on a close to final the intent syntax, and then check how this compares with the SRE syntax.

@dginev
Copy link
Contributor

dginev commented Jun 12, 2023

@physikerwelt What is the remaining goal for the comparison with SRE? It would make sense to compare if we wanted to adapt the Intent syntax to be a better fit with SRE's data-* attribute markup, but I believe that isn't a (current) design goal.

I was actually hoping we would get the SRE author himself to attend a W3C Math meeting and give us his perspective on the Intent effort, but I understand that wasn't possible to arrange for the previous meeting with AT vendors (as documented in #461). Maybe finding a path to such a meeting could be a good motivation for keeping this issue open?

I would be in favor of closing here unless we can redirect the discussion in some practical direction.

@physikerwelt
Copy link
Member Author

To me the goal is to justify the need of intent and demonstrate what the advantages of intent in comparison to the previous SRE format. If one thinks that this is not useful, we can close the issue.

@NSoiffer
Copy link
Contributor

I have asked Volker to join the meeting, but he's been busy and (maybe just my impression), not that interested in discussing intent. SRE adds lots of data-xxx attributes trying to categorize parts of the expression so that it can infer the intent. I think a major difference is that intent comes from the author so no inference is needed. Hence, I think SRE's attributes serve a different purpose than intent. Because of the needs of inference, they are much more complicated.

@NSoiffer
Copy link
Contributor

NSoiffer commented Jun 5, 2024

I would keep it open until we have agreed on a close to final the intent syntax, and then check how this compares with the SRE syntax.

It seems like we have a final intent syntax, although we still are adding concept names.

@physikerwelt: is there something more that you are waiting on? Can we close this issue?

@physikerwelt
Copy link
Member Author

The comparison between SRE and intent is still an interesting scientific micro contribution, but not relevant to this group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
intent Issues involving the proposed "intent" attr
Projects
None yet
Development

No branches or pull requests

8 participants