#65099 - 31/01/2002 11:47
JEmplode sort order
|
old hand
Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
|
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);
_________________________
Toby Speight 030103016 (80GB Mk2a, blue) 030102806 (0GB Mk2a, blue)
|
Top
|
|
|
|
#65100 - 28/02/2002 06:26
Re: JEmplode sort order
[Re: tms13]
|
pooh-bah
Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
|
What does the setStrength(Collator.PRIMARY) actually mean?
|
Top
|
|
|
|
#65101 - 28/02/2002 06:41
Re: JEmplode sort order
[Re: tms13]
|
pooh-bah
Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
|
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
|
Top
|
|
|
|
#65102 - 28/02/2002 06:43
Re: JEmplode sort order
[Re: mschrag]
|
old hand
Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
|
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...
_________________________
Toby Speight 030103016 (80GB Mk2a, blue) 030102806 (0GB Mk2a, blue)
|
Top
|
|
|
|
#65103 - 28/02/2002 06:47
Re: JEmplode sort order
[Re: tms13]
|
pooh-bah
Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
|
I ended up using Collator.getInstance() which gives me a locale-specific collator.
|
Top
|
|
|
|
#65105 - 28/02/2002 06:54
Re: JEmplode sort order
[Re: tms13]
|
carpal tunnel
Registered: 13/07/2000
Posts: 4180
Loc: Cambridge, England
|
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
|
Top
|
|
|
|
#65106 - 28/02/2002 06:55
Re: JEmplode sort order
[Re: mschrag]
|
old hand
Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
|
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.
_________________________
Toby Speight 030103016 (80GB Mk2a, blue) 030102806 (0GB Mk2a, blue)
|
Top
|
|
|
|
#65107 - 28/02/2002 06:59
Re: JEmplode sort order
[Re: mschrag]
|
old hand
Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
|
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...))
_________________________
Toby Speight 030103016 (80GB Mk2a, blue) 030102806 (0GB Mk2a, blue)
|
Top
|
|
|
|
#65108 - 28/02/2002 07:31
Re: JEmplode sort order
[Re: peter]
|
old hand
Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
|
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...
_________________________
Toby Speight 030103016 (80GB Mk2a, blue) 030102806 (0GB Mk2a, blue)
|
Top
|
|
|
|
#65109 - 28/02/2002 07:55
Re: JEmplode sort order
[Re: tms13]
|
pooh-bah
Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
|
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
|
Top
|
|
|
|
#65110 - 28/02/2002 07:55
Re: JEmplode sort order
[Re: tms13]
|
pooh-bah
Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
|
|
Top
|
|
|
|
#65111 - 28/02/2002 09:05
Re: JEmplode sort order
[Re: mschrag]
|
old hand
Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
|
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.
_________________________
Toby Speight 030103016 (80GB Mk2a, blue) 030102806 (0GB Mk2a, blue)
|
Top
|
|
|
|
#65112 - 28/02/2002 09:14
Re: JEmplode sort order
[Re: tms13]
|
pooh-bah
Registered: 09/09/2000
Posts: 2303
Loc: Richmond, VA
|
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
|
Top
|
|
|
|
#65113 - 28/02/2002 09:25
Re: JEmplode sort order
[Re: mschrag]
|
old hand
Registered: 30/07/2001
Posts: 1115
Loc: Lochcarron and Edinburgh
|
The "marked=yes" advanced search was the first search I made. It was cool when it suddenly started working!
_________________________
Toby Speight 030103016 (80GB Mk2a, blue) 030102806 (0GB Mk2a, blue)
|
Top
|
|
|
|
|
|