Alternative for python-mathdom

你。 提交于 2019-12-07 02:34:09

问题


I'd like to convert a MathML expression to an equation string in python, for which the MathDOM module should be good for.

An example would be:

<math xmlns="http://www.w3.org/1998/Math/MathML">
   <lambda>
     <bvar><ci>A</ci></bvar>
     <bvar><ci>B</ci></bvar>
     <apply>
         <plus/>
         <ci>A</ci>
         <ci>B</ci>
     </apply>
   </lambda>
</math>

should map to "A + B". This should obviously work with more complex expressions.

However, it is quite old and not working properly with new versions of the xml module (trying to include the wrong module structure, etc.)

Does anyone know useful alternatives?


回答1:


Best solution so far: libsbml

from libsbml import *
ast = readMathMLFromString(xmlString)
f = FunctionDefinition(2,4)
f.setMath(ast)
kl = KineticLaw(2,4)
kl.setMath(f.getBody())
kl.getFormula()

Ok for me since I'm already working with it but far from a general solution.



来源:https://stackoverflow.com/questions/6188082/alternative-for-python-mathdom

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!