- From: Barry Nauta <bnauta@vub.ac.be>
- Date: Wed, 26 Nov 2008 12:17:10 +0100
- To: public-sparql-dev@w3.org
- Message-ID: <31c699ec0811260317k30f93effrc0e314b181ece29@mail.gmail.com>
Hello all, For the university, we need to calculate the compatibility of two persons, based on their FOAF-profiles. My idea was (amongst others) to take a look at the interests of people and resolve whether they are similar. Here is what I am trying to do Person A has the following in his profile: <foaf:interest rdf:resource="http://en.wikipedia.org/wiki/Taekwondo" /> Person B has the following: <foaf:interest rdf:resource="http://en.wikipedia.org/wiki/Soccer" /> Via an ontology, I would like to conclude that they are both interested in sports: <owl:Class rdf:ID="Sports" /> <owl:Class rdf:ID="Taekwondo"> <subClassOf rdf:resource="#Sports"/> <label xml:lang="en">Taekwondo</label> <label xml:lang="nl">Taekwondo</label> <owl:sameAs rdf:resource="http://en.wikipedia.org/wiki/Taekwondo" /> </owl:Class> <owl:Class rdf:ID="Soccer"> <rdfs:subClassOf rdf:resource="#Sports" /> <label xml:lang="en">Soccer</label> <label xml:lang="nl">Voetbal</label> </owl:Class> I would like to get the information using SPARQL and that is where things go wrong: Test for one person only using Jena: Model schemaModel = ModelFactory.createDefaultModel().read(" http://localhost/f/sports.owl.txt"); Model instanceModel = ModelFactory.createDefaultModel().read(fstUrl); Model infModel = ModelFactory.createRDFSModel(schemaModel, instanceModel); String queryString = "PREFIX foaf: <http://xmlns.com/foaf/0.1/> " + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " + "PREFIX ont: <http://localhost/f/sports.owl.rdf> " + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " + "SELECT ?personId ?interest " + " WHERE { " + " ?person a foaf:Person . " + " ?person foaf:interest ?interest . " + " ?interest a ont:Sport . " + " OPTIONAL { ?person foaf:maker ?personId } . " + " OPTIONAL { ?person foaf:mbox ?personId } . " + " OPTIONAL { ?person foaf:mbox_sha1sum ?personId } . " + "}"; Query query = QueryFactory.create(queryString); QueryExecution qe = QueryExecutionFactory.create(query, infModel); ResultSet results = qe.execSelect(); ResultSetFormatter.out(System.out, results); Any input appreciated Barry
Received on Wednesday, 26 November 2008 12:51:05 UTC