INTERACT FORUM

Please login or register.

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

Author Topic: Expression Help  (Read 1121 times)

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Expression Help
« on: April 05, 2020, 10:18:26 pm »

Hi all,

I'm trying to create a couple of new views organized by individuals taken from semicolon-delimited lists.

Example:
I want a view scheme that sorts by individual (classical) Vocalists. Some albums might have some tracks with [Vocalist(s)] containing only "Peter Pears" (say) some might have "Peter Pears; John-Mark Ainsley" and some might have "Peter Pears;" + any number of additional vocalists. In the view scheme, however, there'd only be one "Pears, Peter" listed and then all the tracks he's on.

Not sure if this would be some kind of Regex (which I suck at) or ListItem or something else I'm not thinking of.

Any idea(s)?

Thanks!
Logged

DrKNo

  • World Citizen
  • ***
  • Posts: 201
Re: Expression Help
« Reply #1 on: April 06, 2020, 08:19:09 am »

If the field type of vocalists is "List", then that works for you automatically. Just add a new category view that has vocalist as criterion. The automatic first name last name thing is more difficult. I don't think JRiver has a solution on-board, and I don't think there is a perfect heuristic that works with all naming conventions either... This might actually require manual tag grooming.

If an imperfect solution is ok (say "assume last word in name is last name, rest is first name"), then we could come up with a regex that suits your needs.
Logged

DrKNo

  • World Citizen
  • ***
  • Posts: 201
Re: Expression Help
« Reply #2 on: April 06, 2020, 08:22:46 am »

Adding to this: You might create an additional field that acts as expression based on vocalist if you cannot change the field type of vocalist itself.
Logged

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3118
Re: Expression Help
« Reply #3 on: April 06, 2020, 08:27:42 am »

There is a swap function that will swap first and last names, but sometimes manual intervention is necessary.  To do that you need a tag (probably custom) that has the names swapped by the function, but that you can manually override as needed.  This is often done with a custom tag that you can edit and then the final tag  equals that custom tag if it is populated, otherwise it uses the swap function.  I do no know how swap works on lists.
Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression Help
« Reply #4 on: April 06, 2020, 10:33:50 am »

From someone on Interact, I borrowed this expression for [Composer], which I made into a custom field [Composer Name Swap]:

Code: [Select]
if(!regex([Composer], /#^([^,]+)\s+([^,]*?)$#/),
   [Composer],
   regex(listclean([Composer], 2, / ),
         /#^(?:(I+|[JS]r\.?)\s+)?(\S+)(.*)$#/, -1)[R2]/,/ listclean([R3], 2, / )[R1]
)

There's an issue in it with a couple of Czech names (Leos Janáček comes to mind: I get "Jana, Leos cek, because of the accent, I guess), but otherwise it works well. So that's easily adaptible for [Vocalist(s)], and since all my vocalist tags are retrieved from AllMusic, they're pretty standardized.

So yes, I just need the Regex. Thanks so much for all of your help!

Logged

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3118
Re: Expression Help
« Reply #5 on: April 06, 2020, 11:18:12 am »

The MC name swap works fine for most cases.  MrC did the original name swap Regex here.  Matt turned that logic into a standard function. Glynor was also actively involved.

The problem comes with weird names that do not follow any standard rules.

How do you swap Vincenza Garelli della Morea? 

I do not think you are ever going to get a function that handles all cases correctly. Either you live with the possible anomalies or build a manual override logic with custom tags.
Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression Help
« Reply #6 on: April 06, 2020, 03:34:06 pm »

@dtc, Sure, I'm fine with little things like Janacek or the one you gave. The main thing I'm looking for is an expression to pull individual vocalists (and soloists too, for a different view scheme) out of a semicolon-delimited list with 1 or more possible names, so that all instances of "Peter Pears" or "Dietrich Fischer-Dieskau" can be seen under one entry (in the view) for "Pears, Peter" or "Fischer-Dieskau, Dietrich."

So I need an expression that will pull out individual names from the list before worrying about the swap. I'm guessing, again, a Regex of some kind, but as I said I really suck at building those.
Logged

dtc

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 3118
Re: Expression Help
« Reply #7 on: April 06, 2020, 03:44:26 pm »

OK. I was just addressing the name swapping issue. I am not a List guy, so someone else will have to help you the best way to build your view. DrKNo says it should just work.
Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression Help
« Reply #8 on: April 06, 2020, 04:04:30 pm »

Yeah, I tried just [Vocalist(s)] as my first category in a category view. It works as advertised when there's only 1 vocalist, but if there is a list, then I get the whole list. What I'd like, if it's possible (and maybe it's not) is every vocalist has their own category, then when I click on "Peter Pears," I can see all the [Composers], then all the [AMG Work Names] (my tag for [Composition]) he's on. I have a [Conductor] view scheme like this, but since there's usually only 1 conductor for a given orchestral work, I don't run into any problems. But with the list . . . that's where I'm running into difficulty.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression Help
« Reply #9 on: April 06, 2020, 06:46:37 pm »

This I think is a general deficiency in the way MC deals with fields that are actually lists.  Actors is another example.

If I'm in theater view and browsing movies, it's easy to display the actors field, and I can arrow down to it.  But I can't select and "pivot search" on an individual item in the list, like Robert DeNiro.  I only search on the entire list of actors, and that's just not useful.  What I want is "show me other movies with Robert DeNiro. What I get is "here are other movies that also have any actors that are in this movie.

This pivot search functionality works great if it's a single entry field, like Director.

You're having the same problem here.

Now it is easy to construct a view that will show you all tracks that have a particular vocalist, but you have to enumerate each vocalist beforehand.  MC has no automated way to decompose a listed field and present them as individual items or search on them as individual items.

I wish it did, because it would be especially useful for theater view where it is problematic to "type in" a search.

There is new functionality for parsing strings and lists that has been built into the expression language that allow you to pull individual vocalists out of the field.

Please see the regular list and string manipulation functions here:
https://wiki.jriver.com/index.php/Expression_Language

And also see the new functions that were just added into the expression language (and are not in the wiki yet) from this thread:
https://yabb.jriver.com/interact/index.php/topic,124543.0.html
Logged

Moe

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 718
  • Hi
Re: Expression Help
« Reply #10 on: April 06, 2020, 08:19:33 pm »

This is an issue that drives me nuts.  At one point it looked like they were going to make a change so that it worked in a logical way.  But that idea seemed to die on the vine.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression Help
« Reply #11 on: April 06, 2020, 08:34:13 pm »

This is an issue that drives me nuts.

I think you mean it drives you bananas.

Seriously, we should give that other thread a bump.  What it's really talking about is a dynamic expression: an expression search based not on a pre-typed-in expression, but one that takes an input as a variable.  In this case the variable would be the name of the actor selected.
Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression Help
« Reply #12 on: April 06, 2020, 10:59:41 pm »

I ended up getting some off-forum help on this that pretty much solved my problem, though there might be some names that give the new Swap some issues; still this works for now:

Code: [Select]
swap([Vocalist(s)])&datatype=[list]
That gives me what I was seeking in the OP (see attachment).

Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Expression Help
« Reply #13 on: April 06, 2020, 11:07:55 pm »

Not that anyone cares, but a couple more views. Once I click on "Pears, Peter" in the previous image, I get to all the [Composers]'s works he's sung in (first image) and then within "Bach, Johann Sebastian," I can see the specific works. This is exactly what I was seeking.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Expression Help
« Reply #14 on: April 07, 2020, 12:04:42 am »

Good for you.  I've never tried the &datatype modifier before.  It actually does enumerate all the items in the list, and it works with Actors too.  Unfortunately I don't think there's any way to link to this from the existing Actors field in Theater View (which of course concerns Moe and me more than you.)
Logged
Pages: [1]   Go Up