Skip to content

Semantic Embedding Examples

Volker Sorge edited this page Apr 14, 2015 · 19 revisions

Some simple examples of embedded semantic tree. Note that for readability the attributes have been abbreviated

Original MathML:

<math>
  <mi>a</mi>
  <mo>+</mo>
  <mi>b</mi>
  <mo>+</mo>
  <mi>c</mi>
</math>

Semantic Tree:

<stree>
  <infixop role="addition" id="5">
    +
    <content>
      <operator role="addition" id="1">+</operator>
      <operator role="addition" id="3">+</operator>
    </content>
    <children>
      <identifier role="latinletter" font="italic" id="0">a</identifier>
      <identifier role="latinletter" font="italic" id="2">b</identifier>
      <identifier role="latinletter" font="italic" id="4">c</identifier>
    </children>
  </infixop>
</stree>

Semantically enriched MathML:

<math>
  <mrow semantic-type="infixop" semantic-role="addition" id="5" semantic-content="1,3" semantic-children="0,2,4">
    <mi semantic-type="identifier" semantic-role="latinletter" id="0" semantic-parent="0">a</mi>
    <mo semantic-type="operator" semantic-role="addition" id="1" semantic-operator="infixop,+" semantic-parent="1">+</mo>
    <mi semantic-type="identifier" semantic-role="latinletter" id="2" semantic-parent="2">b</mi>
    <mo semantic-type="operator" semantic-role="addition" id="3" semantic-operator="infixop,+" semantic-parent="3">+</mo>
    <mi semantic-type="identifier" semantic-role="latinletter" id="4" semantic-parent="4">c</mi>
  </mrow>
</math>

Original MathML:

<math>
  <mn>5</mn>
  <mo>=</mo>
  <mn>3</mn>
  <mo>+</mo>
  <mn>2</mn>
</math>

Semantically enriched MathML:

<math>
  <mrow semantic-type="relseq" semantic-role="equality" id="6" semantic-content="1" semantic-children="0,5">
    <mn semantic-type="number" semantic-role="integer" id="0" semantic-parent="0">5</mn>
    <mo semantic-type="relation" semantic-role="equality" id="1" semantic-operator="relseq,=" semantic-parent="1">=</mo>
    <mrow semantic-type="infixop" semantic-role="addition" id="5" semantic-content="3" semantic-children="2,4" semantic-parent="5">
      <mn semantic-type="number" semantic-role="integer" id="2" semantic-parent="2">3</mn>
      <mo semantic-type="operator" semantic-role="addition" id="3" semantic-operator="infixop,+" semantic-parent="3">+</mo>
      <mn semantic-type="number" semantic-role="integer" id="4" semantic-parent="4">2</mn>
    </mrow>
  </mrow>
</math>

Observe that for the semantic interpretation the original MathML tags are pretty irrelevant. E.g., writing numbers as identifiers still yields the same semantic markup.

Original MathML:

<math>
  <mi>5</mi>
  <mo>=</mo>
  <mi>3</mi>
  <mo>+</mo>
  <mi>2</mi>
</math>

Enriched MathML:

<math>
  <mrow semantic-type="relseq" semantic-role="equality" id="6" semantic-content="1" semantic-children="0,5">
    <mi semantic-type="number" semantic-role="integer" id="0" semantic-parent="0">5</mi>
    <mo semantic-type="relation" semantic-role="equality" id="1" semantic-operator="relseq,=" semantic-parent="1">=</mo>
    <mrow semantic-type="infixop" semantic-role="addition" id="5" semantic-content="3" semantic-children="2,4" semantic-parent="5">
      <mi semantic-type="number" semantic-role="integer" id="2" semantic-parent="2">3</mi>
      <mo semantic-type="operator" semantic-role="addition" id="3" semantic-operator="infixop,+" semantic-parent="3">+</mo>
      <mi semantic-type="number" semantic-role="integer" id="4" semantic-parent="4">2</mi>
    </mrow>
  </mrow>
</math>
Clone this wiki locally