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 自动生成标签