-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Semantic Embedding Examples
Some simple examples of embedded semantic tree. Note that for readability the attributes of the MathML elements have been abbreviated. Usually they have a 'semantic-' prefix.
<mi semantic-type="identifier" semantic-role="latinletter" semantic-id="1" semantic-parent="3">b</mi>
is shortened to
<mi type="identifier" role="latinletter" id="1" parent="3">b</mi>
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 type="infixop" role="addition" id="5" content="1,3" children="0,2,4">
<mi type="identifier" role="latinletter" id="0" parent="5">a</mi>
<mo type="operator" role="addition" id="1" operator="infixop,+" parent="5">+</mo>
<mi type="identifier" role="latinletter" id="2" parent="5">b</mi>
<mo type="operator" role="addition" id="3" operator="infixop,+" parent="5">+</mo>
<mi type="identifier" role="latinletter" id="4" parent="5">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 type="relseq" role="equality" id="6" content="1" children="0,5">
<mn type="number" role="integer" id="0" parent="6">5</mn>
<mo type="relation" role="equality" id="1" operator="relseq,=" parent="6">=</mo>
<mrow type="infixop" role="addition" id="5" content="3" children="2,4" parent="6">
<mn type="number" role="integer" id="2" parent="5">3</mn>
<mo type="operator" role="addition" id="3" operator="infixop,+" parent="5">+</mo>
<mn type="number" role="integer" id="4" parent="5">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 type="relseq" role="equality" id="6" content="1" children="0,5">
<mi type="number" role="integer" id="0" parent="6">5</mi>
<mo type="relation" role="equality" id="1" operator="relseq,=" parent="6">=</mo>
<mrow type="infixop" role="addition" id="5" content="3" children="2,4" parent="6">
<mi type="number" role="integer" id="2" parent="5">3</mi>
<mo type="operator" role="addition" id="3" operator="infixop,+" parent="5">+</mo>
<mi type="number" role="integer" id="4" parent="5">2</mi>
</mrow>
</mrow>
</math>
Original MathML:
<math>
<mi>a</mi>
<mo>+</mo>
<mi>b</mi>
<mo>-</mo>
<mi>c</mi>
<mo>+</mo>
<mi>d</mi>
</math>
Semantically enriched MathML:
<math>
<mrow type="infixop" role="addition" id="9" content="5" children="8,6">
<mrow type="infixop" role="subtraction" id="8" content="3" children="7,4" parent="9">
<mrow type="infixop" role="addition" id="7" content="1" children="0,2" parent="8">
<mi type="identifier" role="latinletter" id="0" parent="7">a</mi>
<mo type="operator" role="addition" id="1" operator="infixop,+" parent="7">+</mo>
<mi type="identifier" role="latinletter" id="2" parent="7">b</mi>
</mrow>
<mo type="operator" role="subtraction" id="3" operator="infixop,-" parent="8">-</mo>
<mi type="identifier" role="latinletter" id="4" parent="8">c</mi>
</mrow>
<mo type="operator" role="addition" id="5" operator="infixop,+" parent="9">+</mo>
<mi type="identifier" role="latinletter" id="6" parent="9">d</mi>
</mrow>
</math>
Original MathML:
<math>
<mi>a</mi>
<mo>+</mo>
<mi>b</mi>
<mo>∘</mo>
<mi>c</mi>
<mi>d</mi>
<mo>+</mo>
<mi>e</mi>
<mo>∘</mo>
<mi>f</mi>
</math>
Semantically enriched MathML:
<math>
<mrow type="infixop" role="addition" id="10" content="1,6" children="0,13,14">
<mi type="identifier" role="latinletter" id="0" parent="10">a</mi>
<mo type="operator" role="addition" id="1" operator="infixop,+" parent="10">+</mo>
<mrow type="infixop" role="multiplication" id="13" content="3" children="2,12" parent="10">
<mi type="identifier" role="latinletter" id="2" parent="13">b</mi>
<mo type="operator" role="multiplication" id="3" operator="infixop,∘" parent="13">∘</mo>
<mrow type="infixop" role="implicit" id="12" content="11" children="4,5" parent="13">
<mi type="identifier" role="latinletter" id="4" parent="12">c</mi>
<mrow type="operator" role="multiplication" id="11" children="" operator="infixop," parent="12"/>
<mi type="identifier" role="latinletter" id="5" parent="12">d</mi>
</mrow>
</mrow>
<mo type="operator" role="addition" id="6" operator="infixop,+" parent="10">+</mo>
<mrow type="infixop" role="multiplication" id="14" content="8" children="7,9" parent="10">
<mi type="identifier" role="latinletter" id="7" parent="14">e</mi>
<mo type="operator" role="multiplication" id="8" operator="infixop,∘" parent="14">∘</mo>
<mi type="identifier" role="latinletter" id="9" parent="14">f</mi>
</mrow>
</mrow>
</math>
The latter contains an implicit operation, resulting in an empty mrow. The question is: What should we do with elements that are introduced by the semantic interpretation but not part of the original MathML. All these are invisible characters: invisible times, invisible comma, function application.
To illustrate the point clearer:
Original MathML:
<math>
<mi>a</mi>
<mi>b</mi>
</math>
Semantic Tree:
<stree>
<infixop role="implicit" id="3">
<content>
<operator role="multiplication" id="2"></operator>
</content>
<children>
<identifier role="latinletter" font="italic" id="0">a</identifier>
<identifier role="latinletter" font="italic" id="1">b</identifier>
</children>
</infixop>
</stree>
Semantically enriched MathML:
<math>
<mrow type="infixop" role="implicit" id="3" content="2" children="0,1">
<mi type="identifier" role="latinletter" id="0" parent="3">a</mi>
<mrow type="operator" role="multiplication" id="2" children="" operator="infixop," parent="3"/>
<mi type="identifier" role="latinletter" id="1" parent="3">b</mi>
</mrow>
</math>
While in the semantic tree a new content operator is introduced, there is no equivalent MathML element. Do empty mrows really matter? This is the rendering:
Original MathML: a b
Semantically enriched MathML: a b
The more complex example from above.
Original MathML: a + b ∘ c d + e ∘ f
Semantically enriched MathML: a + b ∘ c d + e ∘ f
Original MathML:
<math>
<msubsup>
<mi>∑</mi>
<mi>b</mi>
<mi>c</mi>
</msubsup>
<mi>b</mi>
<mi>c</mi>
<mo>+</mo>
<mi>a</mi>
</math>
Semantic Tree:
<stree>
<infixop role="addition" id="11">
+
<content>
<operator role="addition" id="6">+</operator>
</content>
<children>
<bigop role="sum" id="10">
<children>
<limboth role="sum" id="3">
<children>
<largeop role="sum" id="0">∑</largeop>
<identifier role="latinletter" font="italic" id="1">b</identifier>
<identifier role="latinletter" font="italic" id="2">c</identifier>
</children>
</limboth>
<infixop role="implicit" id="9">
<content>
<operator role="multiplication" id="8"></operator>
</content>
<children>
<identifier role="latinletter" font="italic" id="4">b</identifier>
<identifier role="latinletter" font="italic" id="5">c</identifier>
</children>
</infixop>
</children>
</bigop>
<identifier role="latinletter" font="italic" id="7">a</identifier>
</children>
</infixop>
</stree>
Semantically enriched MathML:
<math type="infixop" role="addition" id="11" children="10,7" content="6">
<mrow type="bigop" role="sum" id="10" children="3,9" parent="11">
<msubsup type="limboth" role="sum" id="3" children="0,1,2" parent="10">
<mi type="largeop" role="sum" id="0" parent="3">∑</mi>
<mi type="identifier" role="latinletter" id="1" parent="3">b</mi>
<mi type="identifier" role="latinletter" id="2" parent="3">c</mi>
</msubsup>
<mrow type="infixop" role="implicit" id="9" children="4,5" content="8" parent="10">
<mi type="identifier" role="latinletter" id="4" parent="9">b</mi>
<mrow type="operator" role="multiplication" id="8" children="" operator="infixop," parent="9"/>
<mi type="identifier" role="latinletter" id="5" parent="9">c</mi>
</mrow>
</mrow>
<mo type="operator" role="addition" id="6" operator="infixop,+" parent="11">+</mo>
<mi type="identifier" role="latinletter" id="7" parent="11">a</mi>
</math>