Category Formulas and Variables -> regular expression not working correct

Started by axel.hennig, September 09, 2022, 02:23:00 PM

Previous topic - Next topic

axel.hennig

I tried to replicate this example from the help-page (see screenshot): https://www.photools.com/help/imatch/cat_formulas.htm
sc1.jpg

To be concrete, this example:
@Category[@All|Beach|Daytona]
Therefore I've created a category-tree like the following:
@All
|- Beach
  |- Daytona
|- Beach Club
  |- Hawaii
|- Mountains
  |- Daytona
|- Places
  |- Beach
      |- Daytona

I've added to the categories:
"@All|Beach|Daytona":        pic_1
"@All|Beach Club|Hawaii":    pic_2
"@All|Mountains|Daytona":    pic_3
"@All|Places|Beach|Daytona": pic_4

But when I enter in a new category the formula
@Category[@All|Beach|Daytona]it just returns pic_1. But the help says it should also return pic_2 ("@All|Beach Club|Hawaii"). And from my understanding it should also return pic_3 ("@All|Mountains|Daytona"). But it doesn't.

VarToy-app
The VarToy-app gives - at least to my understanding - a different result. When entering
{File.Categories|filter:@All|Beach|Daytona}it returns:

pic_1: Beach|Daytona        -> correct
pic_2: Beach Club|Hawaii    -> correct
pic_3: Mountains|Daytona    -> correct
pic_4: Places|Beach|Daytona  -> wrong (should be just empty / no result)

thrinn

Thinking about your question, I am not sure anymore if the example in the help ist correct. From my understanding, @Category[@All|Beach|Daytona] should look for categories which contain "Beach" in their first level and, at the same time, "Daytona" in the second level. Thus, this expression should find "@All|Beach|Daytona" as well as "@All|Beach Club|Daytona Beach Club", but not "@All|Beach Club|Hawaii", because the second level does not match.

Regarding Vartoy: The filter expression is just a RegExp, so you will get all categories containing "Beach" or "Daytona" anywhere in the full category path. This is not directly comparable to the special handling in the @Category formula.
Thorsten
Win 10 / 64, IMatch 2018, IMA

axel.hennig

Hi Thorsten,
thanks for looking into this topic.

I think the question is if @Category[@All|Beach|Daytona] is:
  • looking for "Beach" in first level AND "Daytona" in second level or
  • looking for "Beach" in first level OR "Daytona" in second level

The help says: When you expression begins with @All, IMatch considers every level specified individually. To me that sounds like an OR not an AND.


Regarding your VarToy reply: I think it should be exactly the same behaviour, not differently. Why: The help says: The filter function allows you to filter the categories of a file by a regular expression, identical to the @Category[] category formula

thrinn

Quote from: axel.hennig on September 09, 2022, 04:58:22 PMRegarding your VarToy reply: I think it should be exactly the same behaviour, not differently. Why: The help says: The filter function allows you to filter the categories of a file by a regular expression, identical to the @Category[] category formula
I understand what you are saying. But @Category[] has two different syntax variants, so to say: One where the argument starts with @All, another one where the argument does not start with @All. Vartoy behaves more like the second variant described here.
Thorsten
Win 10 / 64, IMatch 2018, IMA

Mario

I think the Hawaii example is wrong. I wrote that several years ago, so this is an old glitch.
I also think that IMatch works correctly.

You run a regexp on the following pattern:

@All|Beach|Daytona

which means that IMatch processes each level individually. So it first matches :

Beach

on all your top-level categories. Which finds two matches:

Beach|Daytona
Beach Club|Hawaii

Now it matches Daytona (next level down) against

Daytona
Hawaii

and the only match is Daytona of course. It would work when your categories are named:

Beach|Daytona
Beach Club|Daytona

or when your expression is something like:

"@Category[@All|Beach|.*]"

I shall update the help to fix this.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

axel.hennig