I have been trying to find help with negation but I can't find anything in the O'reilly book or even online. Plus the online documentation ("How to use PyParsing" or even the class documentation) is no longer accessible.
Here's what I would like to do. I want to match a bunch of verbs (like assert, state, argue etc.). However, in the data "states" occurs a lot with the word "united". Therefore, I would like to prevent that particular match for "states" if the word "united" occurs before it. So. I thought I could do something along the lines of the idea Paul mentioned here: http://bytes.com/topic/python/answers/763719-regular-expression-negate-word-not-character
However, 'ignore()' doesn't seem to work. Here's my complication expression:
and here's what I did for the ignore:
assertVerb.ignore(Literal("united") + Literal("states"))
Another complicating thing is that this assertVerb element participates in a more complex element with other elements around it. Any idea what I am doing wrong?
Thanks in advance!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been trying to find help with negation but I can't find anything in the O'reilly book or even online. Plus the online documentation ("How to use PyParsing" or even the class documentation) is no longer accessible.
Here's what I would like to do. I want to match a bunch of verbs (like assert, state, argue etc.). However, in the data "states" occurs a lot with the word "united". Therefore, I would like to prevent that particular match for "states" if the word "united" occurs before it. So. I thought I could do something along the lines of the idea Paul mentioned here:
http://bytes.com/topic/python/answers/763719-regular-expression-negate-word-not-character
However, 'ignore()' doesn't seem to work. Here's my complication expression:
assertVerb = Literal("points out") | Literal("point out") | oneOf("asserts assert \
claims claim \
writes write \
assumes assume \
contends contend \
alleges allege \
considers consider \
indicates indicate \
argues argue \
suggests suggest \
declares declare \
ignores ignore \
overlooks overlook \
generalizes generalize \
advocates advocate \
maintains maintain \
feels feel \
states state \
thinks think \
holds hold")
and here's what I did for the ignore:
assertVerb.ignore(Literal("united") + Literal("states"))
Another complicating thing is that this assertVerb element participates in a more complex element with other elements around it. Any idea what I am doing wrong?
Thanks in advance!