Last.fm tool: Compare your profile to an artist?'; printMessages( "compareartist" ); echo 'With the form below, you can compare your musical preferences with that of an artist.
How you match up with $artist"; $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 $artist is $similarity, at "; 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 $artist"; 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 $artist's genres (scaled up for easy reading). If you want to better fit your profile to the artist, listen to more music coloured red, and less blue, if possible. "; echo ' |
||||
|