Page 1 of 1

Search with negation

Posted: Wed Oct 10, 2007 2:10 pm
by manubat
I would like to have a search funnction with a negation system :
for example : looking for in the IPTC keywords : "car" NOT "red"
or "landscape" NOT "beach"

It can be very useful to deal with image management with IPTC keywords !

Thank you

PCRE is the best

Posted: Wed Oct 10, 2007 4:56 pm
by Clo
:) Hello !

• That needs RegEx, not supported yet, AFAIK…

• I hope that Pierre'll use a powerful library, like PCRE (I've already translated its doc in French for another APP.)

:mrgreen: KR
Claude
Clo

Posted: Wed Oct 10, 2007 8:20 pm
by foxyshadis
Really? What's the regular expression for 'landscape AND sunset NOT beach'? I've been using them for years, and I don't know how you'd create a general whole word not-match regex, and multiple AND/OR conditions leads to exponentially increasing expression complexity. If you have one, it's something I've been looking for for years.

Regex is useful but it doesn't really solve this class of problem, but generating a set of regexes and a simple for loop from them can. They're complimentary though, it would be nice to have the power of a regex available as well.

Assertions

Posted: Wed Oct 10, 2007 11:55 pm
by Clo
—> foxyshadis

:) Hello !

• Despite I'm not expert at this, it seems that the problem above could be solved using complex assertions.
Example from the PCRE doc:
foo(?!bar)

matches any occurrence of "foo" that is not followed by "bar"
- Isn't it that manubat needs ?
- You can find a lot of pages at THIS SITE, seems complete.
- We had to look for such a doc because the original pages @ the Cambridge University (UK) have been moved¦renamed,
and it's impossible to find the original whole doc now.
- That permitted to give a valid link in our translated doc…

• Anyway, RegEx are missing in XnView…

EDIT :
From user icfu-friend :
1. car(?!.*red)|landscape(?!.*beach)
2. landscape(?=.*sunset)(?!.*beach)

- With an alternative in (1.) since you added a word… ;)

:mrgreen: KR
Claude
Clo

PCRE in French

Posted: Thu Oct 11, 2007 12:10 am
by Clo
—> manubat

:) Hello !

• In THIS FOLDER is the translation I talk of above.
- It's only the part that the author of this application had chosen… so big, though !
- Just look for the “Expressions régulières” chapter, and don't care the rest.

:mrgreen: KR
Claude
Clo

Re: Search with negation

Posted: Thu Oct 11, 2007 12:52 am
by oops66
manubat wrote:I would like to have a search funnction with a negation system :
for example : looking for in the IPTC keywords : "car" NOT "red"
or "landscape" NOT "beach"
It can be very useful to deal with image management with IPTC keywords !
Thank you
You mean "a sentence" of IPTC keywords ? into one line like:
big red car
small black car
...? or only keywords like:
big
red
car
....
In both cases, yes, it is very useful to have (AND and NAND):
"car" NAND (and not) "red"
and
"car" AND (and) "red"
The OR function, is not useful, because only one keyword is enough in this case. ( NOR fuction is not very useful too in this case).

In case of "sentences" of IPTC keywords you can already have the AND function by typing "red car" or "car red" with: (tools\search\IPTC\keywords\red car (with all of the words) then search , browse and create file liste if needed .

Maybe a seconde new IPTC line in this menu : tools\search\IPTC\keywords\
with the function NOT is possible ? (without all of the words)
Image

Posted: Thu Oct 11, 2007 5:51 am
by foxyshadis
(?=.*sunset) isn't valid in PCRE or perl, because it's a variable length assertion. Maybe perl 6? But Philip Hazel told me a while back that he has no intention of supporting perl 6 until it's out and finalized. It looks like it'd work, but the compiler just isn't set up to do that. (And just because the docs aren't always up with it, I did try it, hoping it would work, but no luck.) Plus if IPTC keywords (let alone filenames) aren't in alphabetical order, you'd have to include every possible ordering as a separate branch.

If things like that did work, it'd be the optimum solution for implementing all other search modes, certainly.

Posted: Thu Oct 11, 2007 7:03 am
by Icfu
(?=.*sunset) isn't valid in PCRE
Of course it is. This is a look-ahead assertion, not a look-behind.

Icfu