INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Help with expression language ( List Manipulation)  (Read 1536 times)

chrisG81

  • Recent member
  • *
  • Posts: 7
Help with expression language ( List Manipulation)
« on: October 19, 2022, 12:12:50 am »

Hello,

i have a question regarding list manipulation expression.
For Genres and Subgenres I want to maintain only the Tag Genre in the file.
In JRiver I want to split the values in two new fields via expression depending on the value.
I thought ListFind() would be a good idea. For example:
Genre: Pop, Alt Pop, Alternative Rock, Hard Rock, Rock
Expression 1 for Genres: ListFind([Genre], Pop;Rock)
Expression 2 for Subgenres: ListFind([Genre], Alt Pop;Alternative Rock;Hard Rock)

This only works for 1 value, i think for the first. Any ideas how to achieve this?

Thank you for support.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Help with expression language ( List Manipulation)
« Reply #1 on: October 19, 2022, 06:34:43 am »

You can use ListMix() to go through every element of the list.

Solution complexity depends little on how your data is set. e.g do you have genres like Pop/Rock or other genres like Jazz, Blues or whatever etc

If main genres doesn't overlap in the metadata and everything have Pop or Rock then one simple solution could be something like this:

SUB GENRES
Code: [Select]
ListRemove(ListMix(If(Compare(Find([L1],Rock),>,-1),[L1],),,[Genre]),Rock)
Code: [Select]
ListRemove(ListMix(If(Compare(Find([L1],Pop),>,-1),[L1],),,[Genre]),Pop)
GENRE
Code: [Select]
IfElse(
    ListContains([Genre],Rock),
        Rock,
    ListContains([Genre],Pop),
        Pop
)


Zelda test images
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2618
Re: Help with expression language ( List Manipulation)
« Reply #2 on: October 19, 2022, 08:23:14 am »

ListCombine is perfect for this:

Genre: ListCombine([genre], Pop;Rock,;,;,1)
SubGenre: ListCombine([genre], Alt Pop;Alternative Rock;Hard Rock,;,;,1)

Mode 2 of ListCombine seems to be broken. It would be ideal for the subgenres expression as a way to return everything except Pop;Rock:
SubGenre: ListCombine([genre], Pop;Rock,;,;,2)   -> seems to be doing the same as mode 0, adding both lists instead of subtracting

@Matt, can you please take a look?
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42372
  • Shoes gone again!
Re: Help with expression language ( List Manipulation)
« Reply #3 on: October 19, 2022, 08:32:03 am »

We just added the new ListCombine mode in 30.0.20:
NEW: Added another mode to ListCombine(...) expression function to allow outputting only values not common to both lists.

In mode 2, it outputs items not common to both lists.

Running:
ListCombine(a;a;b;c,c;d;e;a,;,;,2)
Outputs:
b;d;e

What do you think should work differently?  Thanks.
Logged
Matt Ashland, JRiver Media Center

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2618
Re: Help with expression language ( List Manipulation)
« Reply #4 on: October 19, 2022, 09:42:11 am »

Actually it seems I was still testing on v29, so that explains why mode 2 was behaving like mode 0  ::)

I think a mode 3 is also needed. A classic Venn diagram is useful here:

Mode 0 = A + B                  -> all elements, deduplicated
Mode 1 = A ∩ B                  -> purple area, common elements only
Mode 2 = (A + B) - (A ∩ B) -> green+blue, remove common purple elements
Mode 3 = A - B                   -> green area, remove B elements

This mode 3 would solve OP's problem:
Genre: ListCombine([genre],Pop;Rock,;,;,1)               -> only Pop/Rock if present
SubGenre: ListCombine([genre],Pop;Rock,;,;,3)         -> all except Pop and Rock

Possible bug: the function is not trimming the lists, so a space after/before the comma is actually giving different results:
ListCombine(a;a;b;c,c;d;e;a,;,;,2)   = b;d;e
ListCombine(a;a;b;c,c;d;e;a ,;,;,2)   = a;a;b;d;e;a
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42372
  • Shoes gone again!
Re: Help with expression language ( List Manipulation)
« Reply #5 on: October 19, 2022, 10:19:25 am »

Thanks!

Next build:
Fixed: ListCombine mode 2 was not trimming spaces when it built the list.
NEW: Added a mode 3 to ListCombine that's A - B.
Logged
Matt Ashland, JRiver Media Center

chrisG81

  • Recent member
  • *
  • Posts: 7
Re: Help with expression language ( List Manipulation)
« Reply #6 on: October 19, 2022, 10:34:16 am »

Wow! Just came back from work. Thank you for the comprehensive replies. I hope i have a little spare time this evening to check out some of the suggested solutions.
Looking forward to the next build!
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2618
Re: Help with expression language ( List Manipulation)
« Reply #7 on: October 19, 2022, 10:34:51 am »

Thanks!

Next build:
Fixed: ListCombine mode 2 was not trimming spaces when it built the list.
NEW: Added a mode 4 to ListCombine that's A - B.

Thank you! I assume you mean mode 3 :)
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 42372
  • Shoes gone again!
Re: Help with expression language ( List Manipulation)
« Reply #8 on: October 19, 2022, 11:25:03 am »

Thank you! I assume you mean mode 3 :)

What are you even talking about ;D
Logged
Matt Ashland, JRiver Media Center

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Help with expression language ( List Manipulation)
« Reply #9 on: October 19, 2022, 11:49:38 am »

ListCombine is better and simpler than my take if genre and sub genre lists can be hard coded

But what about something generic which doesn't need any hard coded lists. One could think that sub genre always has the root word as a last word. so if there is only one word it would be root genre and other with two or more words are sub genres.

Following that logic something like this could also be used

Calculated Genre:
ListMix(If(Compare(Find([L1],/ ),=,-1),[L1],),,[Genre])

Calculated Sub Genre:
ListMix(If(Compare(Find([L1],/ ),=,-1),,[L1]),,[Genre])
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2618
Re: Help with expression language ( List Manipulation)
« Reply #10 on: October 19, 2022, 11:58:44 am »

"New Age"  ;D

The list of ID3 genres contains a few more genres having a space:
https://www.esm.rochester.edu/ears/docs/lame/id3.html

PS: What is "109 - Porn Groove" :o
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Help with expression language ( List Manipulation)
« Reply #11 on: October 19, 2022, 12:01:52 pm »

rm -fr genre="new age"

E: That id3 genre list though for me seems to also have some sub genres. There are also couple of actual genres which have two words. Anyway maybe easier to add those couple as exceptions in the expression than add all of them.
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Help with expression language ( List Manipulation)
« Reply #12 on: October 19, 2022, 12:02:58 pm »

PS: What is "109 - Porn Groove" :o
Probably something deutch from the 70's  ;D
Logged
Pages: [1]   Go Up