How to parse a list using pyparsing

N

Nitin Madnani

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top