Re: make sure entire string was parsed

2005-09-13 Thread Steven Bethard
Paul McGuire wrote: > I still don't know the BNF you are working from Just to satisfy any curiosity you might have, it's the Penn TreeBank format: http://www.cis.upenn.edu/~treebank/ (Except that the actual Penn Treebank data unfortunately differs from the format spec in a few ways.) > 1. I'm s

Re: make sure entire string was parsed

2005-09-12 Thread Paul McGuire
Steve - Wow, this is a pretty dense pyparsing program. You are really pushing the envelope in your use of ParseResults, dicts, etc., but pretty much everything seems to be working. I still don't know the BNF you are working from, but here are some other "shots in the dark": 1. I'm surprised fun

Re: make sure entire string was parsed

2005-09-12 Thread Steven Bethard
Steven Bethard wrote: > Paul McGuire wrote: > I have to differentiate between: (NP -x-y) and: (NP-x -y) I'm doing this now using Combine. Does that seem right? >> >> >> If your word char set is just alphanums+"-", then this will work >> without doing anything unnatural

Re: make sure entire string was parsed

2005-09-12 Thread Steven Bethard
Paul McGuire wrote: >>>I have to differentiate between: >>> (NP -x-y) >>>and: >>> (NP-x -y) >>>I'm doing this now using Combine. Does that seem right? > > If your word char set is just alphanums+"-", then this will work > without doing anything unnatural with leaveWhitespace: > > from pyparsin

Re: make sure entire string was parsed

2005-09-11 Thread Paul McGuire
Steve - >>I have to differentiate between: >> (NP -x-y) >>and: >> (NP-x -y) >>I'm doing this now using Combine. Does that seem right? If your word char set is just alphanums+"-", then this will work without doing anything unnatural with leaveWhitespace: from pyparsing import * thing = Word

Re: make sure entire string was parsed

2005-09-11 Thread Steven Bethard
Paul McGuire wrote: > Thanks for giving pyparsing a try! To see whether your input text > consumes the whole string, add a StringEnd() element to the end of your > BNF. Then if there is more text after the parsed text, parseString > will throw a ParseException. Thanks, that's exactly what I was

Re: make sure entire string was parsed

2005-09-10 Thread Paul McGuire
Steven - Thanks for giving pyparsing a try! To see whether your input text consumes the whole string, add a StringEnd() element to the end of your BNF. Then if there is more text after the parsed text, parseString will throw a ParseException. I notice you call leaveWhitespace on several of your

[pyparsing] make sure entire string was parsed

2005-09-10 Thread Steven Bethard
How do I make sure that my entire string was parsed when I call a pyparsing element's parseString method? Here's a dramatically simplified version of my problem: py> import pyparsing as pp py> match = pp.Word(pp.nums) py> def parse_num(s, loc, toks): ... n, = toks ... return int(n) + 10