How do nested variables work?

Started by Burax, October 29, 2021, 07:10:45 PM

Previous topic - Next topic

Burax

Hi,
i wanted to find out if the persons in IMatch are also included in the XMP keywords - maybe to build a category.
For this I have used this expression in a simplified way:

{File.MD.XMP::iptcExt\PersonInImage\PersonInImage\0|foreach:{File.MD.hierarchicalkeywords|contains:{value},yes,no} }

For example:
File.MD.hierarchicalkeywords = ..anything..;Person|Mike;..
File.MD.XMP::iptcExt\PersonInImage\PersonInImage\0 = Julia;Mike;Peter

I expected the result to be 'no yes no', but apparently the {value} doesn't work here.
Am I doing something wrong here or is it so not possible?

Mario

What does VarToy show for
{File.MD.XMP::iptcExt\PersonInImage\PersonInImage\0|foreach:{File.MD.hierarchicalkeywords}}
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Burax

#2
Hm, this expression simply concatenates the contents of {File.MD.hierarchicalkeywords} with the number of elements in {File.MD.XMP::iptcExt\PersonInImage\PersonInImage\0}..

With the data from the example earlier: Person|MikePerson|MikePerson|Mike
(Without a semicolon in between, of course)

As a filter, I only want to see the images whose (face recognition) persons in IMatch are different from the XMP keywords that were created (e.g. through an external program).
Maybe there is another way.

Mario

#3
The variable first retrieves all persons in the selected image.
For each person it then retrieves the hierarchical keywords, as a semicolon-separated string.
On the resulting string contains is applied.

Quotei wanted to find out if the persons in IMatch are also included in the XMP keywords - maybe to build a category.

This is not exactly clear to me...

Do you want to find persons which also have keywords?
Or persons where the name of the person is also a keyword?
Assigning  a person to a face can assign any number of keywords and categories.

I would probably handle this with a data-driven category.

On Level 1, use the PersonInImage tag. Set "Use Other" to No.
On Level 2, use the hierarchicalSubject tag. Set "Use Other" to No.

This produces a category for each person, and below that a category for each keyword assigned to files with that person.
Would that not achieve what you want to do?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Burax

Ok, the reason for this is simply that I'm new to IMatch. :)
Maybe I see the problem too complicated or the double translation is crap.

I started assigning persons with face recognition.
I forgot to enter the names as keywords in the person editor at the same time.
As a result, I have recognized many faces in IMatch, but not the corresponding names as keywords in the XMP files.
I wanted to build a filter for this difference.

But, I will now simply add all the keywords in the person editor (where they are missing) and IMatch will then rewrite the XMP files.
(Simply 'name' -> 'person|name', maybe something is possible via script.)
Problem solved.

(The question remains, however, why the {value} does not work in the initial expression..  ;))

Mario

Because your value operates on the concatenated list of all keywords used together with the person. Not the result you expect.

When you add (or remove) keywords to a person in the Person Editor, IMatch updates all files linked to that person automatically. This is done in the database and hence quite fast.
When you write-back the next time, the modified keywords and all other pending metadata changes are written to the image and/or sidecar file.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Mario

I've had a look at your variable again. Probably

{File.MD.XMP::iptcExt\PersonInImage\PersonInImage}{File.MD.XMP::iptcExt\PersonInImage\PersonInImage|foreach:{File.MD.hierarchicalkeywords|foreach:{value|contains:Tom,yes,no}}}

prints yes if an image of Tom contains the keyword Tom.

foreach can process a variable or plain text.
The special {value} variable contains the current value of foreach, and when we apply a contains on that value, we can check each keyword individuall.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Burax

Quote from: Mario on November 01, 2021, 01:41:36 PMThe special {value} variable contains the current value of foreach, and when we apply a contains on that value, we can check each keyword individuall.
Ok, i expected that that {value} contains the single name.
(And I don't know that the name is e.g. Tom, because that is variable.)

To understand again, as an example:
The expression {File.MD.XMP::iptcExt\PersonInImage\PersonInImage} produces 'Mike;Julia;Peter;Tom'.
An then {File.MD.XMP::iptcExt\PersonInImage\PersonInImage|foreach:{value}} creates 'MikeJuliaPeterTom'.
Without additional characters or line breaks, the variable {value} contains 4x another single name.
Everything fits.

And if I expand this to the final version {File.MD.XMP::iptcExt\PersonInImage\PersonInImage|foreach:{File.MD.hierarchicalkeywords|contains:{value},yes,no}}, then I would expect that the individual name will also be compared with {File.MD.hierarchicalkeywords} four times.
Because the {value} from the expression belongs to the foreach:.
But that doesn't seem to work, maybe because {value} is nested.
(If {File.MD.hierarchicalkeywords} contains '..;Person|Willy;Person|Julia;..', it should result in 'noyesnono'.)

But, as I said, it doesn't matter, I have to rework the persons anyway.

Thank you again for your work.
I've now done my job and bought the program because I'm still talking about the trial version..  ::)

Mario

Quote(If {File.MD.hierarchicalkeywords} contains '..;Person|Willy;Person|Julia;..', it should result in 'noyesnono'.)

It does.

A file with 4 keywords: beach, sport, ball, sun

{File.MD.hierarchicalkeywords|foreach:[{value}]} => [beach][sport][ball][sun]

{File.MD.hierarchicalkeywords|foreach:{value|contains:s,Y,N}} => NYNY

And thanks for purchasing an IMatch license. I'm sure you will find that this was a good investment. And cheap, too  ;D
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook