modules/tag/models/Tag.php
public function findTagWeights($limit = 20)
    {
        $models = self::find()
            ->orderBy('frequency DESC')
            ->limit($limit)
            -all();

        $total=0;
        foreach ($models as $model) {
            $total+=$model->frequency;
        }

        $tags=[];
        if ($total > 0)
        {
            foreach ($models as $model) {
                $tags[$model->name] = 8 + (int)(16*$model->frequency/($total+10));
            }
            ksort($tags);
        }

        return $tags;
    }
public function findTagWeights($limit = 20)
    {
        $models = self::find()
            ->orderBy('frequency DESC')
            ->limit($limit)
            -all();

        $total=0;
        foreach ($models as $model) {
            $total+=$model->frequency;
        }

        $tags=[];
        if ($total > 0)
        {
            foreach ($models as $model) {
                $tags[$model->name] = 8 + (int)(16*$model->frequency/($total+10));
            }
            ksort($tags);
        }

        return $tags;
    }
Returns tag names and their corresponding weights.
Only the tags with the top weights will be returned.
@param integer the maximum number of tags that should be returned
@return array weights indexed by tag names.