It looks like it could be useful. You'd have to play around with it
with larger expressions to see how well it works. Ideally the library
would be in Python, but if SnuggleTex works well it might be worth
using.

Aaron Meurer

On Wed, Mar 16, 2016 at 1:48 PM, Aman Deep <[email protected]> wrote:
> Thanks for replying Aaron!, That is very useful information!
>
> How about using SnuggleTex for converting Latex to Content MathML?
>
> SnuggleTex is a java library for converting Latex to Content MathML. It is
> issued under 3-clause BSD license.
>
> Thanks.
>
> On Tuesday, 15 March 2016 01:58:47 UTC+5:30, Aaron Meurer wrote:
>>
>> There are two types of MathML, Presentation MathML and Content MathML.
>> Presentation MathML is a markup for formatting expressions, similar to
>> LaTeX. Content MathML has some knowledge of the mathematical
>> expressions they represent. Content MathML is easier to parse to SymPy
>> because it represents an expression tree. Most LaTeX -> MathML
>> converters convert to Presentation MathML, since LaTeX is itself a
>> presentation language.
>>
>> To convert to SymPy, you really need any kind of expression tree, or
>> AST. Converting from that to SymPy would just be a matter of walking
>> the syntax tree and converting it to Python. Content MathML is a good
>> choice for this, but so would many other formats (like a Lisp
>> expression, or some internal format in the Javascript). Presentation
>> MathML and LaTeX are poorer choices, because they don't represent
>> mathematical expressions, they represent 2D rendering of symbols. So
>> for example, if you have x + y, you want something that represents
>> that as an Add node with "x" and "y" subnodes. LaTeX represents this
>> as the string "x + y". But you can also have nonsense LaTeX
>> expressions, like "x + / ^ -" or "\frac{+}{3}". These are valid LaTeX
>> because they represent a valid 2D rendering, but they aren't valid
>> math because there are operators (nodes) that don't have proper syntax
>> (e.g., the + "operator" should have a left and right child,
>> mathematically it doesn't make sense by itself in a fraction).
>>
>> LaTeX is also bad because it's very easy to be ambiguous with it (like
>> "\sin xy", which could mean sin(x*y) or sin(x)*y). While you could
>> probably be careful and only generate unambiguous LaTeX, you still
>> have to reparse that into its own expression tree anyway, in order to
>> do the conversion to SymPy. With that being said, it is useful for an
>> equation editor to be able to export to LaTeX, so you can get the
>> exact representation of what you inputted.
>>
>> Note that unless you design the equation input system so that it's
>> impossible to enter invalid expressions (e.g., when you enter ∫ it
>> immediately requires you to enter an expression and a variable), you
>> will have to have some way to translate from "presentation" to
>> "content".
>>
>> Aaron Meurer
>>
>>
>> On Fri, Mar 11, 2016 at 7:21 AM, Aman Deep <[email protected]> wrote:
>> > If I am able to convert the latex expression to MathML.
>> > Will it be easier to parse MathML to sympy expression?
>> >
>> > Here Is something I found which converts latex to MathML.
>> > https://www.mathtowebonline.com/
>> >
>> > On Friday, 11 March 2016 17:20:48 UTC+5:30, Aman Deep wrote:
>> >>
>> >> I have asked them about it on their irc channel
>> >> irc://irc.freenode.net/mathquill
>> >> Waiting for their reply.. Meanwhile I am trying to make latex work with
>> >> sympy.
>> >>
>> >> Thanks.
>> >>
>> >> On Friday, 11 March 2016 16:01:17 UTC+5:30, Francesco Bonazzi wrote:
>> >>>
>> >>>
>> >>>
>> >>> On Thursday, 10 March 2016 22:58:09 UTC+1, Aman Deep wrote:
>> >>>>
>> >>>> I was able to use mathquill inside jupyter notebook using html &
>> >>>> javascript.
>> >>>>
>> >>>> Here is the code.
>> >>>> http://nbviewer.jupyter.org/gist/hiamandeep/52ccdce87c40fb021048
>> >>>>
>> >>>
>> >>> Excellent.
>> >>>
>> >>>>
>> >>>> So, If I skip the latex part then what should be my approach to
>> >>>> convert
>> >>>> text in input area to sympy expression?
>> >>>
>> >>>
>> >>> Have a look at this conversation:
>> >>> https://github.com/mathquill/mathquill/issues/456
>> >>>
>> >>> Otherwise, you could try to parse the javascript expression tree of
>> >>> mathquill.
>> >>>
>> >>> Try to contact the mathquill developers, maybe they can better advise
>> >>> us.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "sympy" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to [email protected].
>> > To post to this group, send email to [email protected].
>> > Visit this group at https://groups.google.com/group/sympy.
>> > To view this discussion on the web visit
>> >
>> > https://groups.google.com/d/msgid/sympy/6b30bb95-b052-4eeb-9a4e-63cac27f77bd%40googlegroups.com.
>> >
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/c5014bc3-7f9f-4e00-82b2-0670a9e594c3%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2B6Rj0-RsH3NFBdOunnArTjuKffb_7NiJVGEs99BnHDZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to