- # Here we make a halfhearted attempt to separate the tags into "strata" based on weight_total
- # FIXME: code4lib probably has a better algorithm, iirc
- # FIXME: when we get a better algorithm, move to C4
- my $maxstrata = 5;
- my $strata = 1;
- my $previous = 0;
- my $chunk = ($count/$maxstrata)/2;
- my $total = 0;
- my %cloud;
- foreach (reverse @$results) {
- my $current = $_->{weight_total};
- $total++;
- $cloud{$strata}++;
- if ($current == $previous) {
- $_->{cloudweight} = $strata;
- next;
- }
- if ($strata < $maxstrata and
- ($cloud{$strata} > $chunk or
- $count-$total <= $maxstrata-$strata)) {
- $strata++;
- }
- $_->{cloudweight} = $strata;
- $previous = $current;
- }