Fork me on GitHub
#rdf
<
2023-03-29
>
simongray11:03:04

Is the unique identifier in an RDF IRI allowed to contains slashes, i.e. if the namespace is is the full IRI allowed to be ? I cannot find anything on this.

simongray11:03:31

the identifier would then be foo/bar .

rickmoynihan11:03:15

Yes. In SPARQL and turtle (and other but not all serialisation formats), you can specify a BASE e.g.:

BASE <>
SELECT *
WHERE { BIND(<foo/bar> as ?uri) }
This establishes a base uri, which lets you use relative URI paths. If you want to use the BASE as a URI you simply write <>.

🙏 2
simongray11:03:23

too bad Clojure keywords are incompatible… 😐

rickmoynihan11:03:44

Strictly speaking keywords are not incompatible… will reply on main thread.

simongray11:03:00

I would like to do it and it seems like it’s allowed (and even pretty nice), but it also really conflicts with how keywords work in Clojure

simongray11:03:38

you can create them just fine in Clojure (and retrieve their namespace), but the second part breaks in ClojureScript

simongray11:03:37

another thing I noticed is that the name part of a keyword https://clojure.org/reference/reader which would also break a bunch of RDF IRIs in the form of namespaced keywords. This part is strange and doesn’t even seem enforced.

rickmoynihan12:03:03

(keyword "foo.bar.baz/quux.quibble") ;; => :foo.bar.baz/quux.quibble You’re just experiencing a difference between readable forms and the allowed values a keyword can take (anything)… e.g. (keyword "") ;;=> : Not saying this is helpful for you

rickmoynihan12:03:45

ahh sorry missed the bit about clojurescript

rickmoynihan12:03:56

not 100% sure what the behaviour is there

simongray12:03:30

not entirely sure either… it doesn’t happen with keywords created on the CLJS side, but it doesn’t occur with keywords that are transferred via Transit from the backend… so perhaps the extra slashes are messing with transit decoding

rickmoynihan12:03:35

ahh well if you have transit; they may not be compatible with the transit spec.

rickmoynihan12:03:05

though you should be able to define a custom codec for them

simongray12:03:00

yeah… it’s quite strange, I can’t quite pinpoint where the issue is… transit just does (keyword s)

simongray12:03:56

(prn subject
             (type subject)
             (namespace subject)
             (name subject))
        (prn (keyword "dn" "synset/42986")
             (type (keyword "dn" "synset/42986"))
             (namespace (keyword "dn" "synset/42986"))
             (name (keyword "dn" "synset/42986")))
returns (in ClojureScript)
:dn/synset/42986 cljs.core/Keyword nil "dn"
:dn/synset/42986 cljs.core/Keyword "dn" "synset/42986"

simongray12:03:03

subject is the keyword from the backend. Somehow it looks the same as the value created directly on the frontend, but the name becomes the namespace and the namespace is nil . so strange.

simongray12:03:42

from what I can tell, transit is just doing (keyword s) , so the same as I am.

simongray12:03:59

ah no wait, the same stuff happens with (keyword "dn/synset/42986"). I see. So that’s the issue.

simongray12:03:55

still, this does seem to be in undefined territory

simongray12:03:57

(fn [s]
  (let [[ns identifier] (str/split s #"/" 2)]
    (if identifier
      (keyword ns identifier)
      (keyword s))))
that fixed it! (an alternative transit handler for keywords)

simongray08:03:30

or just

(fn [s] (apply keyword (str/split s #"/" 2)))

simongray12:03:50

still I don’t think I will venture down this path as Clojure seems determined to fight me

Eric Scott15:03:05

I wrestled with this stuff a while back myself. You may be interested in https://github.com/ont-app/vocabulary/blob/master/src/ont_app/vocabulary/format.cljc

🙏 2
simongray18:03:06

Thanks @eric.d.scott, I'll take a look at that.

👍 2