Hi R experts,
I would like to find some keywords (e.g., 'cat') in a list of sentences but need to leave out those in which the keyword is preceded by "no" or "not" within three-word distance. For instance, I have four sentences, like
s1: "I have a cat."
s2: "I have no cat"
s3: "I did not have any cat"
s4: "I did not have any dog but I have a cat"
s5: "I have a cat but no dogs"
What is the regular expression I can use with grepl() to find only s1, s4 and s5?
Thanks
Best,
Veda