Closed nicolasGuillouet closed 10 years ago
By the way, your query should have a list of triples, not a single triple.
e.g.,
(def results (kr-sparql/query datas (list (list subject predicate '?/o))))
but that whole thing can be simplified to something like this:
(def results (kr-sparql/query datas `((~subject rdfs/label ?/o)))
Or you could use the RDF API that's designed to query with a single triple.
I got your example to work with a few modifications with the current snapshot version:
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<!-- http://purl.org/NET/c4dm/keys.owl#AFlat -->
<rdf:Description rdf:about="http://purl.org/NET/c4dm/keys.owl#AFlat">
<rdfs:label rdf:datatype="http://www.w3.org/2000/01/rdf-schema#Literal">la bémol</rdfs:label>
</rdf:Description>
</rdf:RDF>
and example:
(require
'[edu.ucdenver.ccp.kr.kb :as kr-kb]
'[edu.ucdenver.ccp.kr.rdf :as kr-rdf]
'[edu.ucdenver.ccp.kr.sparql :as kr-sparql]
'[edu.ucdenver.ccp.kr.jena.kb :as kr-jena]
'[edu.ucdenver.ccp.kr.jena.sparql :as kr-jena-sparql]
'[edu.ucdenver.ccp.kr.jena.rdf :as kr-jena-rdf]
'[edu.ucdenver.ccp.kr.clj-ify :as kr-clj-ify])
(import [java.io FileInputStream]
[java.net URI])
(defn new-store
[]
(binding [edu.ucdenver.ccp.kr.jena.kb/*default-model-type* :owl
edu.ucdenver.ccp.kr.rdf/*use-default-language* false]
(kr-rdf/register-namespaces (kr-kb/kb :jena-mem) '(
("rdf" "http://www.w3.org/1999/02/22-rdf-syntax-ns#")
("rdfs" "http://www.w3.org/2000/01/rdf-schema#")
("xsd" "http://www.w3.org/2001/XMLSchema#")
("skos" "http://www.w3.org/2004/02/skos/core#")
("foaf" "http://xmlns.com/foaf/0.1/")
))))
(def datas (new-store))
(kr-rdf/load-rdf-stream datas (FileInputStream. "test-rdf.rdf") :rdfxml)
(def subject (URI. "http://purl.org/NET/c4dm/keys.owl#AFlat"))
(def predicate (URI. "http://www.w3.org/2000/01/rdf-schema#label"))
(kr-sparql/query datas `((~subject rdfs/label ?/o)))
output:
({?/o "la bémol"})
Please see if you can verify this.
Ok It works fine.
Thanks very much Kevin.
ps : the code is working, but I had a problem for retrieving it from github. The release 1.4.18 seems not to be up to date ... I had to direct download the code before testing it. Perhaps it is normal thing ?
Yes old versions will never change. I didn't push a new version yet until we had it tested. That's what I was asking if you could download from here, compile, and run with the 1.4.19-SNAPSHOT
.
you would have had to do something like:
git clone https://github.com/drlivingston/kr.git kr
cd kr
mvn clean package install
then on that machine KR 1.4.19-SNAPSHOT
will be available.
So I'm assuming that's what you did? If everything is working, I'll push a new version to clojars as 1.4.19
.
That's what I did ;-)
Ok great. Then I'm going to mark this as closed an move toward releasing a new version to Clojars.
Hi Kevin, sorry, but did you forget to release a new version on Clojars ?
Sorry, I lost track of this. I just pushed KR 1.4.19 to Clojars with the relevant fixes for issues 9 and 10.
Current development version has been pushed to 1.4.20-SNAPSHOT.
This issue is created from #9 .
My question was :
on datas :
When I run :
(kr-sparql/query datas '(purl/AFlat rdfs/label ?/o))
it return({?/o #<TypedValue com.hp.hpl.jena.datatypes.BaseDatatype$TypedValue@6084a2ef>})
I tried to declare one method :(defmethod kr-clj-ify/clj-ify BaseDatatype$TypedValue [kb l] (.lexicalValue l))
without success :-(.After Kevin's request the code I use is :
Nicolas