rdf

simongray 2023-03-29T11:27:04.597419Z

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.

simongray 2023-03-29T11:27:31.444179Z

the identifier would then be foo/bar .

2023-03-29T11:55:15.624919Z

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 <>.

šŸ™ 1
simongray 2023-03-29T11:56:23.121409Z

too bad Clojure keywords are incompatible… 😐

2023-03-29T11:57:44.619929Z

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

simongray 2023-03-29T11:39:00.333249Z

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

simongray 2023-03-29T11:44:38.023819Z

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

simongray 2023-03-29T11:46:37.293029Z

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.

2023-03-29T12:00:03.051179Z

(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

2023-03-29T12:00:45.923159Z

ahh sorry missed the bit about clojurescript

2023-03-29T12:00:56.737849Z

not 100% sure what the behaviour is there

simongray 2023-03-29T12:07:30.683589Z

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

2023-03-29T12:08:35.178739Z

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

2023-03-29T12:09:05.738279Z

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

simongray 2023-03-29T12:13:00.685679Z

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

simongray 2023-03-29T12:19:56.582259Z

(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"

simongray 2023-03-29T12:22:03.144359Z

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.

simongray 2023-03-29T12:23:42.077319Z

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

simongray 2023-03-29T12:24:59.884769Z

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

simongray 2023-03-29T12:25:55.369439Z

still, this does seem to be in undefined territory

simongray 2023-03-29T12:29:57.412589Z

(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)

simongray 2023-03-30T08:46:30.291789Z

or just

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

simongray 2023-03-29T12:30:04.246809Z

thanks @rickmoynihan

simongray 2023-03-29T12:32:50.261889Z

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

2023-03-29T15:37:05.919349Z

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

šŸ™ 1
simongray 2023-03-29T18:57:06.729019Z

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

šŸ‘ 1