How to parse a list using pyparsing

Discussion in 'Python' started by Nitin Madnani, Jul 31, 2004.

  1. 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
    Nitin Madnani, Jul 31, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    19
    Views:
    1,119
    Daniel Vallstrom
    Mar 15, 2005
  2. Replies:
    0
    Views:
    293
  3. Nathan Harmston

    Problem using Optional pyparsing

    Nathan Harmston, Aug 16, 2007, in forum: Python
    Replies:
    2
    Views:
    445
    Paul McGuire
    Aug 16, 2007
  4. Paul McGuire
    Replies:
    2
    Views:
    333
    John Machin
    Jun 20, 2008
  5. 7stud --

    optparse: parse v. parse! ??

    7stud --, Feb 20, 2008, in forum: Ruby
    Replies:
    3
    Views:
    183
    7stud --
    Feb 20, 2008
Loading...

Share This Page