Search with negation

Ideas for improvements and requests for new features in XnView Classic

Moderators: XnTriq, xnview

Post Reply
manubat
Posts: 7
Joined: Wed Oct 10, 2007 1:08 pm
Location: Paris

Search with negation

Post by manubat » Wed Oct 10, 2007 2:10 pm

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

User avatar
Clo
XnThusiast
Posts: 4441
Joined: Sun Oct 17, 2004 4:57 am
Location: Bordeaux, France
Contact:

PCRE is the best

Post by Clo » Wed Oct 10, 2007 4:56 pm

:) 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
Old user ON SELECTIVE STRIKE till further notice

User avatar
foxyshadis
Posts: 382
Joined: Sat Nov 18, 2006 8:57 am

Post by foxyshadis » Wed Oct 10, 2007 8:20 pm

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.

User avatar
Clo
XnThusiast
Posts: 4441
Joined: Sun Oct 17, 2004 4:57 am
Location: Bordeaux, France
Contact:

Assertions

Post by Clo » Wed Oct 10, 2007 11:55 pm

—> 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
Last edited by Clo on Thu Oct 11, 2007 4:55 am, edited 1 time in total.
Old user ON SELECTIVE STRIKE till further notice

User avatar
Clo
XnThusiast
Posts: 4441
Joined: Sun Oct 17, 2004 4:57 am
Location: Bordeaux, France
Contact:

PCRE in French

Post by Clo » Thu Oct 11, 2007 12:10 am

—> 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
Old user ON SELECTIVE STRIKE till further notice

User avatar
oops66
XnThusiast
Posts: 1999
Joined: Tue Jul 17, 2007 1:17 am
Location: France

Re: Search with negation

Post by oops66 » Thu Oct 11, 2007 12:52 am

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
Last edited by oops66 on Mon Oct 15, 2007 1:45 am, edited 7 times in total.
XnViewMP 0.82 Linux X64 - Ubuntu 16.04 LTS - X64

User avatar
foxyshadis
Posts: 382
Joined: Sat Nov 18, 2006 8:57 am

Post by foxyshadis » Thu Oct 11, 2007 5:51 am

(?=.*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.

User avatar
Icfu
Posts: 24
Joined: Wed Jun 08, 2005 5:15 am

Post by Icfu » Thu Oct 11, 2007 7:03 am

(?=.*sunset) isn't valid in PCRE
Of course it is. This is a look-ahead assertion, not a look-behind.

Icfu

Post Reply