Saladsamurai
08-10-2009, 06:34 PM
:hi: First , I will start by saying that I am NOT looking for someone to write my code for me. I would just like some guidance/brainstorming to see how different folks might attack this. I have included what I have so far below.
Second, Yeah. I know it is going to be a pain. But I need to do it for work.
Here is an example:
The quadratic formula, x = ( -b + (b^2-4*a*c)^(1/2))/(2*a) would be represented in MathML something like:
<mrow>
<mi>x</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mo form="prefix">−</mo>
<mi>b</mi>
<mo>±</mo>
<msqrt>
<msup>
<mi>b</mi>
<mn>2</mn>
</msup>
<mo>−</mo>
<mn>4</mn>
<mo>⁢</mo>
<mi>a</mi>
<mo>⁢</mo>
<mi>c</mi>
</msqrt>
</mrow>
<mrow>
<mn>2</mn>
<mo>⁢</mo>
<mi>a</mi>
</mrow>
</mfrac>
</mrow>
</math>
I need to take the above code and turn in back into a regular (calculator-type) expression like x = ( -b + (b^2-4*a*c)^(1/2))/(2*a) .
Now what I (with help) have accomplished so far is to have all of the code read onto VBA and inserted into an array such that each element of the ML is an element of the array.
For example:
Array(1) = <mrow>
Array(2) = <mi>
Array(3) = x
Array(4) = <mi>
and soooo on...
Okay let's add in some of these element's definitions:
mrow—displays its subelements in a horizontal row.
mi—represents an identifier such as the name of a function or variable.
mo—represents an operator or delimiter.
mn—represents a number.
My idea at this point is as follows:
The tags that get wrapped around each term are analogous to sets of parenthesis; so I will describe my idea in terms of this analogy.
My idea is based on the distance between a left and right parenthesis. When working with a simple arithmetic expression with multiple sets of parentheses, one could denote the location of the 'innermost' left parenthesis and then denote its corresponding right parenthesis as the 'closest' right-parenthesis to it.
The backing out from the center of the expression, the next left-parenthesis would be matched to the 2nd closest right-parenthesis and so on.
This analogy could be extended on to the MathML by noting that there now different 'flavors' of parenthesis.
I know there will be some difficulties that arise. For one, how do actually determine what should be the 'innermost' set?
Secondly, what if there is a 'lone pair' somewhere for example ((()))+()
Even the most "trivial" of suggestions would be appreciated.
Thanks!!
Second, Yeah. I know it is going to be a pain. But I need to do it for work.
Here is an example:
The quadratic formula, x = ( -b + (b^2-4*a*c)^(1/2))/(2*a) would be represented in MathML something like:
<mrow>
<mi>x</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mo form="prefix">−</mo>
<mi>b</mi>
<mo>±</mo>
<msqrt>
<msup>
<mi>b</mi>
<mn>2</mn>
</msup>
<mo>−</mo>
<mn>4</mn>
<mo>⁢</mo>
<mi>a</mi>
<mo>⁢</mo>
<mi>c</mi>
</msqrt>
</mrow>
<mrow>
<mn>2</mn>
<mo>⁢</mo>
<mi>a</mi>
</mrow>
</mfrac>
</mrow>
</math>
I need to take the above code and turn in back into a regular (calculator-type) expression like x = ( -b + (b^2-4*a*c)^(1/2))/(2*a) .
Now what I (with help) have accomplished so far is to have all of the code read onto VBA and inserted into an array such that each element of the ML is an element of the array.
For example:
Array(1) = <mrow>
Array(2) = <mi>
Array(3) = x
Array(4) = <mi>
and soooo on...
Okay let's add in some of these element's definitions:
mrow—displays its subelements in a horizontal row.
mi—represents an identifier such as the name of a function or variable.
mo—represents an operator or delimiter.
mn—represents a number.
My idea at this point is as follows:
The tags that get wrapped around each term are analogous to sets of parenthesis; so I will describe my idea in terms of this analogy.
My idea is based on the distance between a left and right parenthesis. When working with a simple arithmetic expression with multiple sets of parentheses, one could denote the location of the 'innermost' left parenthesis and then denote its corresponding right parenthesis as the 'closest' right-parenthesis to it.
The backing out from the center of the expression, the next left-parenthesis would be matched to the 2nd closest right-parenthesis and so on.
This analogy could be extended on to the MathML by noting that there now different 'flavors' of parenthesis.
I know there will be some difficulties that arise. For one, how do actually determine what should be the 'innermost' set?
Secondly, what if there is a 'lone pair' somewhere for example ((()))+()
Even the most "trivial" of suggestions would be appreciated.
Thanks!!