Leave a comment

Comments 9

av8rmike March 3 2007, 02:31:01 UTC
That's not quite the way I envisioned the algorithm, but I'd trust your experience.

Reply

kunzite1 March 3 2007, 03:34:35 UTC
which? the quicksort was provided by someone else.

i came up with the rest with some ripping of the tagcloud fontsize code.

do you have a different idea that might be more efficient? if so, i'm willing to take a look at it.

feel free to take this code, refine it, and comment with your changes.

Reply

av8rmike March 4 2007, 00:57:27 UTC
Hmmm, can you do a heap sort or merge sort with S2? ;)

I was going to suggest sorting tags by usage first, selecting the top 20, then re-sorting. However, it's probably not efficient to do so much sorting, and I see that quicksort function works only on string arrays.

Reply

kunzite1 March 4 2007, 03:35:30 UTC
you can do heap or merge if you can simplify it into s2 functions. :P

this is what i do:
  1. run through TagDetails (Page::visible_tag_list()) to get highest use count while making a hash of TagDetails based on TagDetail.use_count
  2. run through hash while copying TagDetail data, calculating font size, and creating an array of tag names (strings), then stop when max amount of list items has been reached
  3. quicksort tag names (strings) so that we know which order to print them in
  4. run through tag names (strings) and print tag links based on saved information (strings) in hash
what you seem to be proposing is:
  1. sort linear array of TagDetails (Page::visible_tag_list()) by usage (TagDetail.use_count), but stop when max amount of list items is reached

Reply


wasd March 3 2007, 05:56:44 UTC
i'm newbie in all that stuff, there should i write this in order to make the cloud work the way i want?

Reply

kunzite1 March 3 2007, 13:15:18 UTC
if you have a custom layer you'd be putting this code in there.

it'd be easier for me to give more specific instructions if you made your layer(s) publically viewable and gave me the layerid numbers.

Reply

wasd March 3 2007, 14:40:22 UTC
I'm not using a custom layer, the cloud is already in s2expressive, in the sidebar thingie.

Also I dont know how to make my layers publically viewable :(

Reply

kunzite1 March 3 2007, 22:11:41 UTC
yes, the cloud is in the sidebar thingy but you wanted to alter the TagsPage to have a cloud but only include the 20 most used tags. that takes some alteration of the code.

and i forgot to check one thing that would make or break this. you need a paid/permanent account to use custom layers. :\

Reply


(The comment has been removed)

kunzite1 May 8 2007, 05:22:14 UTC
i... don't quite understand what you're looking for.

a lot of the code contained in this entry is there because of how hash tables work. if i iterate over the hash, it won't be in alpha order. it'd be in the order as defined by the hash function.

do you want a
    of tag links? do you want a comma- or space-separated list?

    the idea that i'm getting of what you want would be much much simpler than the code here.

Reply


Leave a comment

Up