Thanks, I'll try to make my function the more generic I can.
El martes, 2 de julio de 2013 21:01:00 UTC+2, Ondřej Čertík escribió: > > On Tue, Jul 2, 2013 at 12:32 PM, peibol <pab...@gmail.com <javascript:>> > wrote: > > I think xml2dict cannot accomplish it, since I get the same key for > multiple > > values... > > > > For example: mathml_prueba='''<mrow> <mfrac> <mrow> <mn>3</mn> </mrow> > > <mrow> <mn>5</mn> </mrow> </mfrac> </mrow> ''' > > > > I get the following dict: > > {'mrow': {'mfrac': {'mrow': [{'mn': '3'}, {'mn': '5'}]}}} > > Notice the merged 'mrow' key... > > > > Any suggestion for a xml lib to parse the expression? > > lxml seems to be able to parse the expression: > > http://nbviewer.ipython.org/5912034 > > Ondrej > > > > > > > El martes, 2 de julio de 2013 19:53:28 UTC+2, peibol escribió: > >> > >> The mathdox box produces Presentation Mathml. > >> > >> Sympy produces Content Mathml in the printing module, but there is the > c2p > >> function in utils module that converts Content Mathml into Presentation > >> Mathml. > >> > >> So I'm trying the xml2dict parsing with presentation mathml... I think > >> that once I have the dict, at least for easy expressions like > fractions, > >> with addings, algebraic... it's nothing more than a -sophisticated- > >> replacement with some parenthesis abuse. > >> > >> El martes, 2 de julio de 2013 19:38:08 UTC+2, Aaron Meurer escribió: > >>> > >>> Just to be clear, is this presentation mathml or content mathml? I > >>> believe the latter would be much easier to parse. > >>> > >>> Aaron Meurer > >>> > >>> On Tue, Jul 2, 2013 at 12:03 PM, Ondřej Čertík <ondrej...@gmail.com> > >>> wrote: > >>> > On Tue, Jul 2, 2013 at 10:35 AM, Stefan Krastanov > >>> > <krastano...@gmail.com> wrote: > >>> >> I am sorry, I do not think there is an out-of-the-box way to do > this > >>> >> currently. > >>> >> > >>> >> What I can suggest is to use the xml2dict python library to parse > the > >>> >> openmath xml and then write your own small routine for traversing > the > >>> >> dictionary and transforming it into a sympy expression. > >>> >> > >>> >> If you do this I am sure that the sympy team would be very > interested > >>> >> to have your work merged. > >>> > > >>> > Absolutely. Pablo, if you would send us a PR that could do that, > >>> > that would be awesome. > >>> > > >>> > Ondrej > >>> > > >>> >> > >>> >> > >>> >> On 2 July 2013 18:22, peibol <pab...@gmail.com> wrote: > >>> >>> Hehe, they don't write the expression in MathML, I'm not that kind > of > >>> >>> demon. > >>> >>> > >>> >>> They enter expressions in a textarea by means of > >>> >>> http://mathdox.org/formulaeditor/, from which I can get the > openmath > >>> >>> or the > >>> >>> (presentation) mathml .The web app is for K12 students, well 12-16 > >>> >>> years > >>> >>> old, so I think this way to enter mathematical expressions is one > of > >>> >>> the > >>> >>> easiest... > >>> >>> > >>> >>> El martes, 2 de julio de 2013 18:17:19 UTC+2, Stefan Krastanov > >>> >>> escribió: > >>> >>>> > >>> >>>> This is probably not very helpful, but why require the students > to > >>> >>>> write their results in MathML? It is not a very natural way to > write > >>> >>>> expression. On the other hand, if you use valid python expression > it > >>> >>>> would probably be much easier. > >>> >>> > >>> >>> -- > >>> >>> 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 sympy+un...@googlegroups.com. > >>> >>> To post to this group, send email to sy...@googlegroups.com. > >>> >>> Visit this group at http://groups.google.com/group/sympy. > >>> >>> For more options, visit https://groups.google.com/groups/opt_out. > >>> >>> > >>> >>> > >>> >> > >>> >> -- > >>> >> 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 sympy+un...@googlegroups.com. > >>> >> To post to this group, send email to sy...@googlegroups.com. > >>> >> Visit this group at http://groups.google.com/group/sympy. > >>> >> For more options, visit https://groups.google.com/groups/opt_out. > >>> >> > >>> >> > >>> > > >>> > -- > >>> > 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 sympy+un...@googlegroups.com. > >>> > To post to this group, send email to sy...@googlegroups.com. > >>> > Visit this group at http://groups.google.com/group/sympy. > >>> > For more options, visit https://groups.google.com/groups/opt_out. > >>> > > >>> > > > > > -- > > 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 sympy+un...@googlegroups.com <javascript:>. > > To post to this group, send email to sy...@googlegroups.com<javascript:>. > > > Visit this group at http://groups.google.com/group/sympy. > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > -- 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 sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.