Comparison of parsers in python?

andrew cooke andrew at acooke.org
Sun Sep 20 07:50:53 EDT 2009


On Sep 19, 9:34 pm, Peng Yu <pengyu... at gmail.com> wrote:
> On Sep 19, 6:05 pm, Robert Kern <robert.k... at gmail.com> wrote:
> >http://nedbatchelder.com/text/python-parsers.html
>
> This is more a less just a list of parsers. I would like some detailed
> guidelines on which one to choose for various parsing problems.

it would be simpler if you described what you want to do - parsers can
be used for a lot of problems.

also, the parsers do not exist in isolation - you need to worry about
whether they are supported, how good the documentation is, etc.

and different parsers handle different grammars - see
http://wiki.python.org/moin/LanguageParsing - so if you already have a
particular grammar then your life is simpler if you choose a parser
that matches.


these are the three that i know most about - i think all three are
currently maintained:

for simple parsing problems, i think pyparsing is the most commonly
used - http://pyparsing.wikispaces.com/

my own lepl - http://www.acooke.org/lepl/ - tries to combine ease of
use with some more advanced features

the nltk - http://www.nltk.org/ - is particularly targeted at parsing
natural languages and includes a wide variety of tools.


but for parsing a large project you might be better interfacing to a
compiled parser (lepl has memoisation, so should scale quite well, but
it's not something i've looked at in detail yet).

andrew



More information about the Python-list mailing list