JEmplode sort order

Posted by: tms13

JEmplode sort order - 31/01/2002 11:47

IWBNI JEmplode sorted its right-hand panel the same way that the player sorts its search displays.

The way to do this is to implement a java.text.Collator that rewrites its inputs so that any leading "The" is removed and replaced with ", The" at the end, and then delegates to a Collator aqcuired using

Collator c = Collator.getInstance(Locale.US);
c.setStrength(Collator.PRIMARY);
Posted by: mschrag

Re: JEmplode sort order - 28/02/2002 06:26

What does the setStrength(Collator.PRIMARY) actually mean?
Posted by: mschrag

Re: JEmplode sort order - 28/02/2002 06:41

Turns out that it is really easy ... The new version does this now. Collator = !fast by the way (compared to a call to String.compareTo). Sorting those playlists got quite a bit slower (you can see it most right after downloading the database, initially sorting all those tunes take about 1-1 1/2 seconds for me with just abotu 1000 songs). The playlist table view I can cache a little more aggressively, so it's not too bad.

Mike
Posted by: tms13

Re: JEmplode sort order - 28/02/2002 06:43

setStrength(Collator.PRIMARY) means to treat only differences in base letter as significant (a different to b, but same as a-grave and A). Accents and capitalisation are both ignored. On reflection, Collator.SECONDARY may be more appropriate - that treats letters as different if they are accented, but not if they are capitalised. On further reflection, I don't think the collator strength matters too much at all, as even a full-strength collator will order differences of accent and capitalisation within the same base letter (abCde comes between abcda and abcdz, for instance). Strength is more useful for equality tests.

As you can tell, I only pretend to be an expert at this stuff! The important thing is to use a Collator rather than using Unicode code-point order (which I suspect JEmplode is currently doing). And it might be better to use the user's Locale (Locale.getDefault()) rather than Locale.US...
Posted by: mschrag

Re: JEmplode sort order - 28/02/2002 06:47

I ended up using Collator.getInstance() which gives me a locale-specific collator.
Posted by: mschrag

Re: JEmplode sort order - 28/02/2002 06:48

By the way, thanks
Posted by: peter

Re: JEmplode sort order - 28/02/2002 06:54

any leading "The" is removed and replaced with ", The" at the end

The complete list is "a", "un ", "une ", "the ", "le ", "la " "l'", "les ", "der ", "die ", "das ", "ein ", "eine ", "einen "

although it's just occurred to me that this gets it wrong for Les Dawson.

Peter
Posted by: tms13

Re: JEmplode sort order - 28/02/2002 06:55

In reply to:

Collator = !fast by the way


Yes, that's to be expected, I'm afraid. Collator does provide getCollationKey() which can be used to avoid having to re-computed the comparison each time.

What you do is compute the CollationKey for the field the first time it's needed, and then use its compareTo() method for all future comparisons. CollationKey.compareTo() is supposed to be much faster than Collator.compare(), whose documentation says:
In reply to:

For a one time comparison, this method has the best performance. If a given String will be involved in multiple comparisons, CollationKey.compareTo has the best performance. See the CollationKey class description for an example using CollationKeys.


Posted by: tms13

Re: JEmplode sort order - 28/02/2002 06:59

No - thank you! JEmplode is great, and I'm sure I couldn't have done it.

BTW, what timezone do you use for the times of the alpha versions? The web page just gives a time, which gives a range of 23 hours when you might have uploaded stuff (except I doubt you put it there in the future...))
Posted by: tms13

Re: JEmplode sort order - 28/02/2002 07:31

In reply to:

The complete list is "a", "un ", "une ", "the ", "le ", "la " "l'", "les ", "der ", "die ", "das ", "ein ", "eine ", "einen "


Not "an"? Two birds with one stone, as it catches "an" which is "the" in Gaelic (I have a lot of Capercaillie, Altan, Clannad, etc), though "am" (also "the" wouldn't work so well...
Posted by: mschrag

Re: JEmplode sort order - 28/02/2002 07:55

Yeah -- That's what I do for playlist table view sorting (because I can cache the CollationKey)... I may be able to do some not-good-OO-design-caching of the CollationKeys for the other sort routine too ...

Mike
Posted by: mschrag

Re: JEmplode sort order - 28/02/2002 07:55

EST
Posted by: tms13

Re: JEmplode sort order - 28/02/2002 09:05

Minor typo on the web site:

* Collate "The Birds" as "Bird, The"

"Birds, The", I hope?

Noticed lots of other cool stuff when I upgraded - reading Marked flag (can I set/unset it from JE?) and the playlist options panel (though it doesn't seem to be connected to anything yet). Thanks for the effort you put into JEmplode; it's greatly appreciated.

Posted by: mschrag

Re: JEmplode sort order - 28/02/2002 09:14

You can't set it yet from jEmplode yet -- That's next on my list ... It's dynamic data, not a normal tag, so it's handled a bit differently.

You're right about the typo -- My bad. Incidentally, one thing I have now is a saved advanced search

marked = "Yes"

So you have a playlist that contains all the marked tunes (saved searches in jEmplode appear as a soup-like playlist). You can also copy and paste soup views into normal playlists and it will make a snapshot of the soup view and turn it into a playlist -- Saves time if you have playlists setup for By Artist, By Album, etc.

Mike
Posted by: tms13

Re: JEmplode sort order - 28/02/2002 09:25

The "marked=yes" advanced search was the first search I made. It was cool when it suddenly started working!