Using The Music Ontology for Finding Similar Users

314 views
Skip to first unread message

nomush

unread,
Sep 13, 2012, 1:39:40 AM9/13/12
to music-ontology-sp...@googlegroups.com
Hello Everyone!

I have just started learning about ontologies and am a bit confused as to how to go about implementing actual applications that utilize the music ontology and the Similarity ontology in order to find musical similarities between users. I'm collecting user's music likes (in the form of the artist's/band's name). Here is where it gets a bit fuzzy. 
Is the next next to create an RDF file for each artist/band stating their genre and similar artists/bands and then through the Jena API (I would like to code in Java if possible) query the knowledge base, meaning that if I enter a user's music preferences I would be able to output users with similar musical preferences. 

Thanks in advance, 
Naomi

Bob Ferris

unread,
Sep 13, 2012, 3:51:08 AM9/13/12
to music-ontology-sp...@googlegroups.com
Hi Naomi,

to model a user's music preferences you could utilise the Cognitive
Characteristics Ontology (CCO) [1] as well. There is also an example
that deals with music preferences in the documentation of CCO, see [2].
If have all your required knowledge in your knowledge base you could
write SPARQL queries to get what you need (similarities between users).
You'll maybe even do not need the Similarity Ontology at the beginning.
This might be a further enhanced of your similarity algorithm. You could
utilise it for modelling similarities between music artists, or songs, ...

Cheers,


Bo


[1] purl.org/ontology/cco/core#
[2]
http://purl.org/ontology/cco/cognitivecharacteristics.html#sec-simple-music-preferences-example

Bob Ferris

unread,
Sep 13, 2012, 3:55:50 AM9/13/12
to music-ontology-sp...@googlegroups.com
Hello again,

I forgot one good example, see [1]. It's a remodelling of a former
example modelled with UMIRL.

Cheers,


Bo


[1]
http://purl.org/ontology/cco/cognitivecharacteristics.html#sec-UMIRL-example

nomush

unread,
Sep 13, 2012, 11:52:20 AM9/13/12
to music-ontology-sp...@googlegroups.com
Hi Bo, 

Thank you so much for the quick reply! I'll be sure to check out all the examples and try to implement a basic user similarity knowledge base. Eventually I think I would like to you the Similarity Ontology since I would like to model similarities between artists in order to find deeper more meaningful similarities between users and not just whether they liked the same artist, but I can start with a more simple task. 

Thanks again, 
Naomi

nomush

unread,
Sep 13, 2012, 7:13:34 PM9/13/12
to music-ontology-sp...@googlegroups.com
I have been playing around with the Characteristic Ontology and was able to combine it with the Similarity Ontology and Music Ontology as well. 
In the Music Ontology they have an example query for getting the name's of the artists similar to the given artist to at least 80%. 

Finding the names of the Artists similar to another Artist to at least 80%

 1        PREFIX mo:      <http://purl.org/ontology/mo/>
 2        PREFIX sim:     <http://purl.org/ontology/sim/>
 3        PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
 4        SELECT DISTINCT ?level ?similar_artist_name
 5        WHERE 
 6        {
 7            ?artist  a mo:MusicArtist;
 8                     foaf:name "Shakira".

 9            ?artist  sim:link ?blank.
 10           ?blank   sim:relation mo:similar_to;
 11                    sim:level ?level;
 12                    sim:to ?similar_artist.

 14            ?similar_artist a mo:MusicArtist;
 16                            foaf:name ?similar_artist_name.
 17       }   

First of all, I'm a little confused about the working of this query. Should it return the artists that are at least 80% similar to the given artist?
If this is what it should return, I'm confused about how it does so, since when I run the query on my rdf I just get back all the artists, no matter their level of similarity. 
How can I filter the result so it will only return those artists that have a similarity level of at least 0.8?

Thanks in advance, 
Naomi

Bob Ferris

unread,
Sep 14, 2012, 4:14:32 AM9/14/12
to music-ontology-sp...@googlegroups.com
Hi Naomi,

this is more a generic SPARQL question rather than a Music Ontology
related question. Anyway, I'll give you a hint ;)
You should utilise the FILTER clause [2] of SPARQL to reduce your result
set to artists that have a similarity level of 80%+
This looks like that you have to insert a

FILTER (?level > 0.8)

near the end of your query.

Cheers,


Bo


PS: btw, as source for music artist information you could leverage e.g.
MusicBrainz (includes RDFa in their sites), DBPedia (a partial enhanced
RDF mapping of Wikipedia), or you write an RDF wrapper for the Echo Nest API


[2] http://www.w3.org/TR/sparql11-query/#scopeFilters

Kurt J

unread,
Sep 14, 2012, 11:02:39 AM9/14/12
to music-ontology-sp...@googlegroups.com
Hello Naomi,

I'm a little confused about which similarity ontology you are using.
It seems it is not this one:

http://purl.org/ontology/similarity/

And the namespace you are using (http://purl.org/ontology/sim/)
doesn't resolve to anything for me. I would recommend using the one
at http://purl.org/ontology/similarity/ but I'm a bit biased :)

Then your query might look like:

PREFIX mo: <http://purl.org/ontology/mo/>
PREFIX sim: <http://purl.org/ontology/similarity/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?level ?similar_artist_name
WHERE
{
?artist a mo:MusicArtist;
foaf:name "Shakira".

?blank a sim:Similarity ;
sim:element ?artist;
sim:element ?similar_artist;
sim:weight ?weight.

?similar_artist a mo:MusicArtist;
foaf:name ?similar_artist_name.
} FILTER (?weight > 0.8)

-kurt
> --
> You received this message because you are subscribed to the Google Groups
> "Music Ontology Specification Group" group.
> To post to this group, send email to
> music-ontology-sp...@googlegroups.com.
> To unsubscribe from this group, send email to
> music-ontology-specific...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/music-ontology-specification-group?hl=en.
>

nomush

unread,
Sep 14, 2012, 12:12:32 PM9/14/12
to music-ontology-sp...@googlegroups.com
Thank you both for the reply, I think I need to review SPARQL a bit more :) 
I don't really know how I cam across the similarity ontology that I was using, but http://purl.org/ontology/similarity/ seems well documented so I'll use that one! 

Thanks again, 
Naomi

On Wednesday, September 12, 2012 10:39:41 PM UTC-7, nomush wrote:

Kurt J

unread,
Sep 14, 2012, 1:31:00 PM9/14/12
to music-ontology-sp...@googlegroups.com
You can find some info on the similarity ontology and some examples
that might be helpful in my thesis:

http://kurtisrandom.com/pages/connections-in-music

I've not been working much in the world of RDF lately, but would be
happy to help if i can.
> --
> You received this message because you are subscribed to the Google Groups
> "Music Ontology Specification Group" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/music-ontology-specification-group/-/gPr03C5XBAkJ.

nomush

unread,
Sep 14, 2012, 3:07:20 PM9/14/12
to music-ontology-sp...@googlegroups.com
Hi Kurt, 

A quick question about formatting the RDF file using both the music and similarity ontology. 

I'm not sure how to make the connection between the property mo:similar_to and the sim:similarity. 

I'm trying to say that Shakira is 0.9 similar to Beyonce. 

I have my MusicArtist object:

<mo:MusicArtist rdf:about="http://zitgist.com/music/artist/bf24ca37-25f4-4e34-9aec-460b94364cfc"

<foaf:name>Shakira</foaf:name>


then would I continue with:

<sim:element>...
<sim:element>...

and so on?

Thanks for all your help, 
Kurt
> To unsubscribe from this group, send email to

Kurt J

unread,
Sep 14, 2012, 3:22:04 PM9/14/12
to music-ontology-sp...@googlegroups.com
Using the Similarity Ontology sort-of deprecates using mo:similar_to.
You just don't need that property. Your similarity relation becomes a
"thing". So using n3 notation:

:shakira a mo:MusicArtist;
foaf:name "Shakira" .

:beyonce a mo:MusicArtist;
foaf:name "Beyonce".

:mysim a sim:Similarity;
sim:element :beyonce;
sim:element :shakira;
sim:weight "<some calculated weight value>" .

In most implementations, you'd want :mysim to actually be a blank node
- triple stores tend to store these most efficiently and you would
have no cause to refer to :mysim by name - you'll only refer to it in
terms of it's elements. And then the real strength of this approach
is you can bind additional metadata to the similarity (e.g. what was
used to infer the similarity).

Hopefully this helps. Now the real trick will be filling in your
similarities and their weights :)

-kurt
>> > music-ontology-sp...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > music-ontology-specific...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/music-ontology-specification-group?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Music Ontology Specification Group" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/music-ontology-specification-group/-/0yxT73M14vsJ.
>
> To post to this group, send email to
> music-ontology-sp...@googlegroups.com.
> To unsubscribe from this group, send email to
> music-ontology-specific...@googlegroups.com.

nomush

unread,
Sep 14, 2012, 3:27:11 PM9/14/12
to music-ontology-sp...@googlegroups.com
Thanks that actually helped a lot! 


On Wednesday, September 12, 2012 10:39:41 PM UTC-7, nomush wrote:

nomush

unread,
Sep 14, 2012, 6:04:38 PM9/14/12
to music-ontology-sp...@googlegroups.com
Hello again, 

I have tried using the similarity query, however, I never get any information back. I'm assuming this is due to my rdf file. 
Here it is: 

<?xml version="1.0" encoding="UTF-8"?>

<rdf:RDF 

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#

xmlns:foaf="http://xmlns.com/foaf/0.1/

xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#

xmlns:rss="http://purl.org/rss/1.0/

xmlns:dc="http://purl.org/dc/elements/1.1/

xmlns:html="http://www.w3.org/1999/xhtml"

xmlns:mo="http://purl.org/ontology/mo/"

xmlns:sim="http://purl.org/ontology/similarity/">

 

<mo:MusicArtist rdf:about="http://zitgist.com/music/artist/bf24ca37-25f4-4e34-9aec-460b94364cfc">

<foaf:name>Shakira</foaf:name>

</mo:MusicArtist>

<mo:MusicArtist rdf:about="http://zitgist.com/music/artist/f4d5cc07-3bc9-4836-9b15-88a08359bc63">

<foaf:name>Beyonce</foaf:name>

</mo:MusicArtist>

<sim:Similarity>

<sim:element rdf:about="http://zitgist.com/music/artist/bf24ca37-25f4-4e34-9aec-460b94364cfc"/>

<sim:element rdf:about="http://zitgist.com/music/artist/f4d5cc07-3bc9-4836-9b15-88a08359bc63"/>

<sim:weight>0.9</sim:weight> 

</sim:Similarity>

</rdf:RDF> 

I have a few questions. For the similarity, should I have an rdf:about= the similarity link from the last.fm wrapper? Or am I just complicating things too much? 

While music brainz looks like a great database, I think I'm getting to caught up in all the data available, since I only have the  artists' names and not their mbid. 


I tried querying it using n3 format, however I keep getting errors from the jean api, since I don't think it can handle parsing those formats, so I'm stuck using rdf/xml. 

Naomi

Kurt J

unread,
Sep 14, 2012, 7:17:20 PM9/14/12
to music-ontology-sp...@googlegroups.com
Sorry, my RDF is a bit rusty. Look at this tool - it is your friend:

http://www.rdfabout.com/demo/validator/

So I put my N3 in here - edited it till it was valid and matched yours
(i think):

@prefix mo: <http://purl.org/ontology/mo/> .
@prefix sim: <http://purl.org/ontology/similarity/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<http://zitgist.com/music/artist/bf24ca37-25f4-4e34-9aec-460b94364cfc>
a mo:MusicArtist;
foaf:name "Shakira" .

<http://zitgist.com/music/artist/f4d5cc07-3bc9-4836-9b15-88a08359bc63>
a mo:MusicArtist;
foaf:name "Beyonce".

and the xml version is like:

<?xml version="1.0"?>
<rdf:RDF xmlns:mo="http://purl.org/ontology/mo/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sim="http://purl.org/ontology/similarity/">
<mo:MusicArtist
rdf:about="http://zitgist.com/music/artist/bf24ca37-25f4-4e34-9aec-460b94364cfc">
<foaf:name>Shakira</foaf:name>
</mo:MusicArtist>
<mo:MusicArtist
rdf:about="http://zitgist.com/music/artist/f4d5cc07-3bc9-4836-9b15-88a08359bc63">
<foaf:name>Beyonce</foaf:name>
</mo:MusicArtist>
<sim:Similarity rdf:about="#mysim">
<sim:element rdf:resource="#beyonce" />
<sim:element rdf:resource="#shakira" />
<sim:weight>0.9</sim:weight>
</sim:Similarity>
</rdf:RDF>

I would really invest the effort to learn and work in N3 - this is
really the "zen" syntax of RDF. If you have valid N3, Jena will
definitely swallow it happily enough. What I posted in my email was
"pseudo n3" and not valid.

Hope this helps!

-kurt
> --
> You received this message because you are subscribed to the Google Groups
> "Music Ontology Specification Group" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/music-ontology-specification-group/-/1Tqp2vrbY0kJ.

Kurt J

unread,
Sep 14, 2012, 7:30:38 PM9/14/12
to music-ontology-sp...@googlegroups.com
Sorry, yet again i posted wrong N3 - i cut out a large portion. This
is the valid N3:
:mysim a sim:Similarity;
sim:element <http://zitgist.com/music/artist/f4d5cc07-3bc9-4836-9b15-88a08359bc63>;
sim:element <http://zitgist.com/music/artist/bf24ca37-25f4-4e34-9aec-460b94364cfc>;
sim:weight "0.9" .


And the XML was mangled a bit too b/c i put incorrect (but valid) N3
in the translator:
<sim:Similarity rdf:about="#mysim">
<sim:element>
<mo:MusicArtist
rdf:about="http://zitgist.com/music/artist/f4d5cc07-3bc9-4836-9b15-88a08359bc63">
<foaf:name>Beyonce</foaf:name>
</mo:MusicArtist>
</sim:element>
<sim:element>
<mo:MusicArtist
rdf:about="http://zitgist.com/music/artist/bf24ca37-25f4-4e34-9aec-460b94364cfc">
<foaf:name>Shakira</foaf:name>
</mo:MusicArtist>
</sim:element>
<sim:weight>0.9</sim:weight>
</sim:Similarity>
</rdf:RDF>


nomush

unread,
Sep 14, 2012, 8:10:19 PM9/14/12
to music-ontology-sp...@googlegroups.com
Hi Kurt, 

That validator is extremely helpful :) thanks! Since the rdf file changed from the previous format, the sparql query above will need to change to the following: 
SELECT DISTINCT ?level ?artist_name ?similar_artist_name 
WHERE {
?blank a sim:Similarity; 
sim:element ?one; 
sim:element ?two; 
sim:weight ?level . 
?one a mo:MusicArtist; 
foaf:name ?artist_name . 
?two a mo:MusicArtist; 
foaf:name ?similar_artist_name . 
};
However, nothing is returned...
is there by any chance a sparql query validator?! haha



On Wednesday, September 12, 2012 10:39:41 PM UTC-7, nomush wrote:

Kurt J

unread,
Sep 14, 2012, 8:30:25 PM9/14/12
to music-ontology-sp...@googlegroups.com
re: the sparql query, i'd just start cutting stuff out until you get
some results.
SELECT *
WHERE {
?sub a sim:Similarity;
?pred ?obj .
}

and see if that at least works. can you dump the N3 you've input to pastebin?
> --
> You received this message because you are subscribed to the Google Groups
> "Music Ontology Specification Group" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/music-ontology-specification-group/-/0wzBjyDJiS0J.

nomush

unread,
Sep 17, 2012, 1:14:18 PM9/17/12
to music-ontology-sp...@googlegroups.com
No nothing is being printed out. For now I might not use the similarity ontology and just with who the artist's are similar to and see if that works. 

Thanks, 
Naomi
> To unsubscribe from this group, send email to
Reply all
Reply to author
Forward
0 new messages