vue 自动生成标签_在Vue上构建的last.fm标签云生成器

vue 自动生成标签

lastfm-tag-cloud (lastfm-tag-cloud)

A last.fm tag cloud generator build on Vue!

在Vue上构建last.fm标签云生成器!

标签如何选择和缩放? (How are the tags chosen & scaled?)

Initially, the sample of artists (up to the size and of the time period you specify) is iterated through. For each artist, their top tags are fetched, using artist.getTopTags.

最初,迭代艺术家样本(取决于您指定的大小和时间段)。 对于每个艺术家,使用artist.getTopTags提取其顶级标签。

Each tag in the response has a count for that artist.

响应中的每个标签都有该艺术家的count

Note: This count doesn't seem to be documented anywhere. They cap out at 100, so I am working under the assumption that they're a kind of confidence % as to how apropriate that tag is for that artist.

注意:count似乎未在任何地方记录。 他们的上限为100,因此我假设他们对该艺术家的标签有多大的信心是一种信心。

For each tag on the artist, if I have not seen it before, I initialise a library_total metric for that tag with an initial value of 0.

对于艺术家上的每个标签,如果我以前从未看过,我会为该标签初始化一个library_total指标,其初始值为0

The product of the tag's score on that artist and the user's scrobbles of that artist is then added to that tag's library_total metric.

the tag's score on that artist the user's scrobbles of that artist的乘积然后被添加到该标签的library_total指标。

Once all of the artists are iterated through, the tags are pruned to the top 100 by this library_total metric. This is done to avoid hitting rate limits on the last.fm API in the next step, where I have to call tag.getInfo for every tag.

迭代完所有艺术家之后,此library_total指标library_total标签修剪到前100名。 这样做是为了避免在下一步中达到last.fm API的速率限制,在该步骤中,我必须为每个标签调用tag.getInfo

Each of these 100 tags is then scored as per the following code snippet [source]:

然后这些100个标签中的每一个的得分为每下面的代码片断[ 来源 ]:

score_tags(result){
    for (var tag of result.tags) {
        result.scores[tag] = 0
        /**First, each tagging is weighted by the product of:
         *  - How many times the user has listened to the artist on which the tag was used,
         * and...
         *  - The "count" of that tag on the artist.
         *    I am assuming that this "count" is a confidence % given by last.fm as to the accuracy of the tag on that artist.
         *    I can't find any doccumentation, but this would make sense, as they cap out at 100.
         */
        for (var tagging of result.taggings[tag]) {
            result.scores[tag] += tagging.count/100 * result.listens[tagging.artist]
        }
        /**The sum of all these weighted taggings is then scaled by:
         * 1. How many of the uses of that tag overall fall within the user's library sample (its "uniqueness" to the sample).
         * 
         * 2. How many artists within the sample are tagged with that tag (its "spread" over the sample).
         * 
         * 3. The base 10 logarithm of how many people have used that tag overall (its "reach"; see last.fm API docs).
         *    Base 10 is used so 100 people using the tag makes it twice as significant as 10 people using the tag; a nice balance.
         *    It's also conveniently provided as a function by Math.
         */
        result.scores[tag] = result.scores[tag] 
                                    * (result.tag_meta[tag].library_total / result.tag_meta[tag].total) 
                                    * result.taggings[tag].length * result.taggings[tag].length
                                    * Math.log10(result.tag_meta[tag].reach)
    }
}

I've tried to make this take into account the "uniqueness" of the tag to a user's library, as if they were all just scored by frequency the biggest tag on everyone's clouds would probably just be "all".

我试图考虑到用户库中标签的“唯一性”,就好像它们只是按频率评分一样,每个人的云上最大的标签可能就是“全部”。

翻译自: https://vuejsexamples.com/a-last-fm-tag-cloud-generator-build-on-vue/

vue 自动生成标签

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值