Last.fm tool: Do you fit in?'; printMessages( "comparegroup" ); echo 'With the form below, you can compare your musical preferences with that of a Last.fm group (with at least 15 members).
Please be patient, the script may require up to two full minutes to process your request. The script needs to download and analyze your profiles and their top 50 artists. Last.fm policy states that we can only make 1 database query per second, and the script\'s worst case scenario requires 102 requests. Caching is used to lower the load on user (cache = 10 minutes) and artist (cache = 1 week) database requests, so the scripts usually only take ten-something seconds. How you match up with $group"; $similartags; $similarmax = 0; foreach( $tags1 as $tag => $value ) { $similartags[ $tag ] = min( $tags1[ $tag ], $tags2[ $tag ] ); if( min( $tags1[ $tag ], $tags2[ $tag ] ) > $similarmax ) $similarmax = min( $tags1[ $tag ], $tags2[ $tag ] ); } foreach( $tags2 as $tag => $value ) { $similartags[ $tag ] = min( $tags1[ $tag ], $tags2[ $tag ] ); if( min( $tags1[ $tag ], $tags2[ $tag ] ) > $similarmax ) $similarmax = min( $tags1[ $tag ], $tags2[ $tag ] ); } $similarmax = 0; $similarlength = 0; foreach( $similartags as $tag => $value ) { $similarlength += $value * $value; if( $value > $similarmax ) $similarmax = $value; } // $similarmax = min( $max1, $max2 ); $similarlength = sqrt( $similarlength ); $similarpercentage = round( $similarlength * 10000 ) / 100; ksort( $similartags ); if( $similarpercentage < 33.333 ) { $similarity = "low"; } else if( $similarpercentage < 66.667 ) { $similarity = "moderate"; } else { $similarity = "high"; } echo "The similarity between user $user and group $group is $similarity, at "; echo " You can copy/paste the following BBcode to your group's forum. "; echo '
Musical tag clouds"; echo "The following tag cloud represents the musical preferences of $user (more details and BBCode version of this cloud). "; echo 'The next tag cloud depicts the profile of group $group (more details and BBCode version of this cloud). "; echo 'Similarity cloud"; echo "This tag cloud represents the overlap in musical preferences (similarities have been scaled up for easy reading). "; echo 'Difference cloud"; $differenttags; $differentmax = 0; foreach( $tags1 as $tag => $value ) { $differenttags[ $tag ] = $tags1[ $tag ] - $tags2[ $tag ]; } foreach( $tags2 as $tag => $value ) { $differenttags[ $tag ] = $tags1[ $tag ] - $tags2[ $tag ]; } $differentmax = 0; $differentlength = 0; foreach( $differenttags as $tag => $value ) { $differentlength += $value * $value; if( abs( $value ) > $differentmax ) $differentmax = abs( $value ); } // $differentmax = max( $max1, $max2 ); $differentlength = sqrt( $differentlength ); arsort( $differenttags ); echo "This tag cloud highlights the differences in musical preferences. Blue tags are more prominent in $user's preferences, where red tags belong to $group's prefered genres (scaled up for easy reading). If you want to better fit your profile to the group, listen to more music coloured red, and less blue, if possible. "; echo ' |
|||||
|