How to parse a list using pyparsing
Nitin Madnani
nmadnani at wam.umd.edu
Sat Jul 31 01:27:29 EDT 2004
Hi Guys
I am using pyparsing to parse transformation rules for my natural
language processing application. The rules also have structure to
them, i.e., a rule might look like:
[ A [ B ] ] <--> [ C [ D ] ]
where A, B, C, D are nodes in the rule (although they are usually much
more complex than this)
I have figured out how to parse the nodes out of the rules and return
them like this:
[ [ A, B ], [ C, D ] ]
but I would like to return them in a list with the same hierarchical
structure as in the original rule, i.e., I would like to return:
[ [ A, [ B ] ] , [ C, [ D ] ] ]
I hope that makes sense. Any advice is much appreciated.
Thanks !
Nitin
More information about the Python-list
mailing list