lastfm-tag-cloud
A last.fm tag cloud generator build on Vue!
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.
Each tag in the response has a count
for that artist.
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.
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
.
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.
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.
Each of these 100 tags is then scored as per the following code snippet [source]:
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".