mathdom-devel Mailing List for MathDOM
Brought to you by:
scoder
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
(1) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
From: Mario C. <mar...@to...> - 2008-12-20 11:11:34
|
Hello Stefan, thanks for your reply: I was using pyparsing 1.5.1 (last version) I downgraded to 1.4.2 and now it works! Thanks a lot Mario On Fri, Dec 19, 2008 at 3:24 PM, Stefan Behnel <ste...@be...> wrote: > Hi, > > sorry for the late reply. > > Mario Ceresa wrote: >> I have a problem after I just downloaded and installed MathDOM 0.8. >> >> I tried to do: >> >> from mathml.lmathdom import MathDOM >> >> but it crashes with: >> /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py >> in p_case(self, p_arithmetic_exp, p_bool_expression) >> 289 Suppress(CaselessKeyword('END')) >> 290 ) >> --> 291 p_case.setParseAction(self._parse_case) >> 292 return p_case >> 293 >> >> AttributeError: 'NoneType' object has no attribute 'setParseAction' >> ________________________________________________________________ >> >> It seems to me related to these warning that I receive just before the >> exception is thrown: >> >> /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py:288: >> SyntaxWarning: Cannot combine element of type <type 'NoneType'> with >> ParserElement >> Suppress(CaselessKeyword('ELSE')) + p_arithmetic_exp + >> /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py:289: >> SyntaxWarning: Cannot combine element of type <type 'NoneType'> with >> ParserElement >> Suppress(CaselessKeyword('END')) > > I just tested and it works for me with pyparsing 1.4.2. What version of > pyparsing are you using? > > Stefan > |
From: Stefan B. <ste...@be...> - 2008-12-19 14:24:26
|
Hi, sorry for the late reply. Mario Ceresa wrote: > I have a problem after I just downloaded and installed MathDOM 0.8. > > I tried to do: > > from mathml.lmathdom import MathDOM > > but it crashes with: > /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py > in p_case(self, p_arithmetic_exp, p_bool_expression) > 289 Suppress(CaselessKeyword('END')) > 290 ) > --> 291 p_case.setParseAction(self._parse_case) > 292 return p_case > 293 > > AttributeError: 'NoneType' object has no attribute 'setParseAction' > ________________________________________________________________ > > It seems to me related to these warning that I receive just before the > exception is thrown: > > /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py:288: > SyntaxWarning: Cannot combine element of type <type 'NoneType'> with > ParserElement > Suppress(CaselessKeyword('ELSE')) + p_arithmetic_exp + > /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py:289: > SyntaxWarning: Cannot combine element of type <type 'NoneType'> with > ParserElement > Suppress(CaselessKeyword('END')) I just tested and it works for me with pyparsing 1.4.2. What version of pyparsing are you using? Stefan |
From: Mario C. <mar...@to...> - 2008-12-06 20:00:39
|
Hello, I have a problem after I just downloaded and installed MathDOM 0.8. I tried to do: from mathml.lmathdom import MathDOM but it crashes with: __________________________________________________________ AttributeError Traceback (most recent call last) /home/whitehat/<ipython console> in <module>() /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/lmathdom.py in <module>() 35 36 from mathml import MATHML_NAMESPACE_URI, UNARY_FUNCTIONS ---> 37 from mathml.xmlterm import SaxTerm, dom_to_tree, serialize_dom 38 from mathml.datatypes import Decimal, Complex, Rational, ENotation 39 /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/xmlterm.py in <module>() 79 80 from mathml import MATHML_NAMESPACE_URI ---> 81 from mathml.termparser import term_parsers 82 from mathml.termbuilder import tree_converters 83 /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py in <module>() 537 term_parsers = TermParsing() 538 --> 539 parser = InfixTermParser().p_arithmetic_exp() 540 term_parsers.register_converter('infix_bool', InfixBoolExpressionParser().p_bool_exp()) 541 term_parsers.register_converter('infix_term', parser) /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py in __get__(self, instance, owner) 69 if instance is None: 70 return self ---> 71 result = self.function(instance) 72 def return_result(): 73 return result /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py in p_arithmetic_exp(self) 267 p_identifier = self.tokenizer.p_identifier() 268 p_function = self.p_function(p_arithmetic_exp) --> 269 p_case = self.p_case(p_arithmetic_exp, self.p_bool_expression) 270 271 # numeric values = attribute | number | expression /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py in p_case(self, p_arithmetic_exp, p_bool_expression) 289 Suppress(CaselessKeyword('END')) 290 ) --> 291 p_case.setParseAction(self._parse_case) 292 return p_case 293 AttributeError: 'NoneType' object has no attribute 'setParseAction' ________________________________________________________________ It seems to me related to these warning that I receive just before the exception is thrown: /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py:288: SyntaxWarning: Cannot combine element of type <type 'NoneType'> with ParserElement Suppress(CaselessKeyword('ELSE')) + p_arithmetic_exp + /usr/lib/python2.5/site-packages/mathdom-0.8-py2.5.egg/mathml/termparser.py:289: SyntaxWarning: Cannot combine element of type <type 'NoneType'> with ParserElement Suppress(CaselessKeyword('END')) But I don't know how to move on... Any help is greatly appreciated Thanks Mario |
From: Stefan B. <ste...@be...> - 2007-04-11 08:46:30
|
Hi, chrystiano araujo wrote: > You helped me a lot. i've already installed the lxml1.0. and it's > functioning. Good. > But now, there is another doubt. > can you help me again? I would prefer it if you wrote to the mailing list. Admittedly, there are not a lot of subscribers currently, but at least your questions get archived that way, so that others can find them on the web. > I have to make a Mathml parser with python. So i have to study > mathdom a lot, don't I? What do you need a MathML parser for? How is that more than a validating XML parser? (and how is that different from what MathDOM already gives you?) > and i have only 3 examples as documentation, i think it's not enough. As I said, look at the Python scripts that come with MathDOM. They use quite a big part of the API, so they may give you enough hints already. > doc.serialize("python") > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/usr/local/lib/python2.5/site-packages/mathml/mathdom.py", line > 441, in serialize > return serialize_dom(self._document, output_format, converter) > File "/usr/local/lib/python2.5/site-packages/mathml/xmlterm.py", line > 134, in serialize_dom > tree = dom_to_tree(doc_or_element) > File "/usr/local/lib/python2.5/site-packages/mathml/xmlterm.py", line > 216, in dom_to_tree > tree = _recursive_dom_to_tree(root) > File "/usr/local/lib/python2.5/site-packages/mathml/xmlterm.py", line > 188, in _recursive_dom_to_tree > name = operator.mathtype() > File "/usr/lib/python2.5/site-packages/_xmlplus/dom/FtNode.py", line > 83, in __getattr__ > return getattr(FtNode, name) > AttributeError: class FtNode has no attribute 'mathtype' Hmm, ok, now that's using the PyXML implementation of MathDOM. I'll have to check what's not working here. Any reason you can't keep using MathDOM with lxml? It's the preferred way anyway. Regards, Stefan |
From: Stefan B. <ste...@be...> - 2007-04-08 15:31:40
|
Hi, sorry for the late reply. chrystiano araujo wrote: > i've been using mathdom-0.7. > > there is a doubt. Could you help me, please?? > > In a Quick example: > >>>> from mathml.lmathdom import MathDOM > # use lxml implementation >>>> doc = MathDOM.fromString("+2^x+4*-5i/6", "infix_term") # > parse infix term >>>> [ n.value() for n in doc.xpath(u'//math:cn[@type="integer"]') ] # > find integers > x [2, 4, 6] >>>> for apply_tag in doc.xpath(u'//math:apply[math:plus]'): > # replace '+' with '-' > > ... apply_tag.set_operator(u'minus') tthis line, there is a error > Traceback (most recent call last): > File "<stdin>", line 2, in <module> > AttributeError: 'etree._Element' object has no attribute 'set_operator' I assume you are using a recent version of lxml? The way lxml sets up custom element classes (which are used by MathDOM to implement the MathML namespace) has changed in lxml 1.1. I'll fix MathDOM as soon as possible and release a 0.7.2, but it's not as simple as "change this 0 to 1 and it works". Please use lxml 1.0.x for now, which you can get here: http://codespeak.net/lxml/ Ready-to-install binaries are here: http://cheeseshop.python.org/pypi/lxml/1.0.4 http://cheeseshop.python.org/pypi/lxml/1.0.3 > if do you have any documentation of mathdom, send to me, please. Admittedly, MathDOM is pretty much underdocumented. However, it's not that hard to use, so you should get along once you've got it running. Take a look at the test scripts that come with the distribution. Regards, Stefan |
From: Roman S. <sa...@we...> - 2007-03-02 11:12:33
|
Hello list currently I am working on my Bachelors Thesis on storing characteristics (mathematical formulas), containing several parameters as variables, in an ontology. To instantiate the variable the parameters (real-values) are extracted from different concepts in the ontology. I decided to encode the characteristics via MathML and to store them as XMLLiterals which are to be found as datatype properties in the ontology. The project I am working with uses a Java written GUI that enables the user to instantiate the ontology without writing any OWL but with using drag´n drop and wysiwyg mechanisms. One of my tasks is to implement a feature which enables the user to type in formulas (e.g (x + 5*y) * 42) without using MathML. These formulas should be encoded in MathML and they should be stored in the ontology. On the other hand the program has to be able to instantiate the variables of the given formulas and eventually calculate and return the result. My task is not to write a MathML parser but to implement an exisiting one. Unfortunately I could not find anything that matches my requirements (written in Java). MathDom looks very promising to me and with Jython I might be able to use it as a part of my program. Unfortunately I am not very familiar with Python and I could not find a helpful documentation (sorry, if there is one). I would really appreciate if you could show me how to read exisiting MathML streams and to return Java (or Python) expressions. Thank you, Roman |
From: Stefan B. <beh...@gk...> - 2005-11-04 19:14:29
|
Stefan Behnel wrote: > Jeff Kowalczyk wrote: >> The other option is to include a private copy of the full lxml source and >> apply your patch in place, then have setup.py build and install that in >> a private subdir. If the runtime test for a patched lxml in the default >> python path fails, have the import statement import the private copy. > > With the modified setup.py, you can easily ship lxml with MathDOM. The test > for a patched version also has an option. But lxml is not yet included in > the build process. Once it *is* built, all you have to do is copy the > resulting lxml directory (containing the files etree.so, _elementpath.py > and __init__.py) into the mathml directory. Since the only module that > depends on lxml is mathml.lmathdom, Python will simply look there first and > find the correct version. The tests and examples will *not* find the > patched version, but they are not of interest to an installation anyway. > >> lxml is becoming a core product, even Zope has considered making it a >> dependency. I don't think it will be practical to apply post-release >> patching to lxml in anything but experimental setups or package-private >> copies. > > Ok, sounds reasonable. So maybe it would help to integrate the build > processes of lxml and MathDOM. In that case I'd prefer shipping only the > generated C-code for lxml, i.e. lxml/etree.c, to strip the additional Pyrex > dependency (the latest official Pyrex version is still broken when used > with GCC4, so that is really the right thing to do). I'll have to look into > that. Now that I looked into it, I do no longer think a package private copy of lxml is a good choice. Lxml is part of the API of the mathml.lmathdom module, so existing code will import it directly, i.e. break if it is moved. Multiple installed copies will really confuse users and make its usage difficult. So I finally think that installing the patched version independently is the best choice. I'll keep bugging the lxml maintainer to get my patches in there. Stefan |
From: Stefan B. <beh...@gk...> - 2005-11-04 18:22:33
|
Jeff Kowalczyk wrote: > I don't think mathdom should have split packages. The mathdom setup.py doesn't > need options for that, just runtime import autodetection of whether lxml is > available, or pyxml as the fallback. The PyXML version is not a fallback. It's a different implementation based on the XML DOM Level 2 API, while the lxml version is based on the ElementTree API with XIST-like extensions. While I could implement a certain level of compatibility methods (and I partially did already), I will definitely not reimplement the entire APIs, so the general usage of both APIs will stay different. So in a way it's two packages in one - you have to choose. > My question was whether mathdom doesn't > run (with degraded functionality) on a stock lxml-0.8, in which case you'd need > to test for your patched functions in addition to a successful 'import lxml' > statement. No, because it is based on an implementation style that I had to patch into lxml (namespace implementation by element subclassing), so it will definitely not work with any release version of lxml until that patch is merged. It's pretty simple to test though: .>>> from lxml.etree import ElementBase, SaxTreeBuilder will fail on unpatched systems. > 'pymathdom' is a reasonable name if you think 'mathdom' name will conflict. > Gentoo would call the package 'dev-python/mathdom', so this isn't a problem. In > general, I prefer the distro package name to be the same as the python package > name. Like 'mathml'? :) That would be the first to conflict. Actually, one of the reasons for bundling PyMathML with MathDOM was such a conflict... I still think 'mathml' is a good name for the installed package while 'mathdom' is a good name for the main module. Currently, to the best of my knowledge, MathDOM is the only Python implementation of Content MathML there is, so conflicts are unlikely. *cross-fingers* > I think the direction to go (for Gentoo packaging anyway) is simply to have a > modified ebuild that optionally builds lxml with your lxml patch. The mechanism > is called a USE variable, the Gentoo user would add +mathdom to his lxml > configuration, a rebuild would trigger, and your patch would apply. Ok, fine. > This is all fine for the bleeding edge Gentoo experimenter, but I think that > going forward any lxml patches mathdom prefers will have to be accepted > upstream lxml, or mathdom will need to implement rejected extensions itself in > an intermediary C, pyrex, or python code. I'm actually pretty sure the main patches that make MathDOM work will be accepted. MathDOM is a perfect example why they are great. :) Namespace implementation is exemplified in XIST and it's the best way of doing custom data binding and XML driven APIs/GUIs/etc. http://www.livinglogic.de/Python/xist/Howto.html > The other option is to include a private copy of the full lxml source and apply > your patch in place, then have setup.py build and install that in a private > subdir. If the runtime test for a patched lxml in the default python path > fails, have the import statement import the private copy. With the modified setup.py, you can easily ship lxml with MathDOM. The test for a patched version also has an option. But lxml is not yet included in the build process. Once it *is* built, all you have to do is copy the resulting lxml directory (containing the files etree.so, _elementpath.py and __init__.py) into the mathml directory. Since the only module that depends on lxml is mathml.lmathdom, Python will simply look there first and find the correct version. The tests and examples will *not* find the patched version, but they are not of interest to an installation anyway. > lxml is becoming a core product, even Zope has considered making it a > dependency. I don't think it will be practical to apply post-release patching > to lxml in anything but experimental setups or package-private copies. Ok, sounds reasonable. So maybe it would help to integrate the build processes of lxml and MathDOM. In that case I'd prefer shipping only the generated C-code for lxml, i.e. lxml/etree.c, to strip the additional Pyrex dependency (the latest official Pyrex version is still broken when used with GCC4, so that is really the right thing to do). I'll have to look into that. Stefan |
From: Stefan B. <beh...@gk...> - 2005-11-04 08:21:06
|
Stefan Behnel wrote: > I may consider changing setup.py to check for their availability, too. That > would make it easier for maintainers to split up the package. If you do that, > I'd really appreciate it if you provided both packages, though. > > If it fits the package naming convention, you may call them > > python-mathdom-lxml > and > python-mathdom-pyxml > and the complete package > python-mathdom > > or something in that line. The setup.py in the current CVS version now has a couple of configuration options that should help packagers: ----------------- # python setup.py --help-mathdom MathDOM package install options: --name=XXX : force package name to XXX --contrib-lxml : include lxml sources in 'contrib/lxml/' (False) --no-contrib-lxml : do not include lxml sources --require-imports : check if required packages are installed (False) --no-require-imports : do not check installation --pyxml : build *only* 'mathdom-pyxml' package --lxml : build *only* 'mathdom-lxml' package Current build config : lxml (True), pyxml (True), forced name (None) ----------------- You can checkout my lxml branch (see README) into "contrib/lxml/" in the MathDOM source directory and have it included automatically using "--contrib-lxml". It is not built automatically, though. Is that ok for you? Stefan |
From: Stefan B. <beh...@gk...> - 2005-11-04 06:19:46
|
Hi! I changed the subject to help finding it on the mailing list. Jeff Kowalczyk wrote: > I'm curious to try MathDOM on my Gentoo Linux system. Idly curious, I d= on't > have any real math tasks to use it on, but I planned to at least packag= e up > MathDOM for Gentoo as a result of the experimentation. Sure, go ahead :) I already noticed it's been packaged up for Darwin/Mac-= OS, and I'd really like to see it in other places. > Thanks for writing it. Was for my own needs, but it's grown bigger. :) > Could you clarify the web page documentation regarding whether your pat= ch: > http://mathdom.sourceforge.net/bigfat.patch has been, or will be, accep= ted or > rejected upstream by lxml's maintainers? A smaller part is in lxml-0.8 (released yesterday), so I'll release a new patch against that version soon. Other parts are still pending but most o= f it will be merged into lxml's SVN fairly soon, I hope. The patch is a rather big collection of single patches, so it will take s= ome time until all of them are accepted and merged. None has been rejected so= far and there are actually people using them so it's likely that they will be accepted in one way or another. > It also isnt stated whether this patch (and a rebuilt lxml) is required= for > MathDOM to use lxml (over pyxml), nor if the patch has side effects not= iced by > other lxml-using programs. No side effects were found so far, but I guess that's mainly because thos= e that are there conform with the intention of lxml (heading for ElementTre= e conformance). Most of the patch adds additional (independent) functionali= ty. While you can use MathDOM with PyXML (that's intended), the PyXML version= does not currently support XSLT and RelaxNG validation, so I encourage all use= rs to stick to the lxml version. No XSLT support means no support for Presentat= ional MathML export and the like, so that's a rather big draw back. Literal ter= ms are equally well supported in both versions. If you like, you can make distinct packages, one that excludes mathml/lmathdom.py and does not depend on lxml and one that excludes mathml/mathdom.py and does not depend on PyXML. Even the tests should wor= k since they test for the availability of both modules. I hope I took enoug= h care to make the rest only depend on the Python stdlib. I may consider changing setup.py to check for their availability, too. Th= at would make it easier for maintainers to split up the package. If you do t= hat, I'd really appreciate it if you provided both packages, though. If it fits the package naming convention, you may call them python-mathdom-lxml and python-mathdom-pyxml and the complete package python-mathdom or something in that line. > Gentoo ebuilds make it easy to add patches to the build process. If the= patch > is already accepted by upstream lxml, or is just a generally useful pat= ch, I > could add a USE variable and the conditional patch to dev-python/lxml-0= .7. They > may not accept it into mainline portage, but it would be there in > bugs.gentoo.org for any who were interested. Right, Gentoo 'gen=E8re tout' (generates everything - french) :) - longes= t OS installation ever :) So I guess separate packages would be the way to go.= I'll include that in the CVS version, so you can be the first to test it... :) Stefan |