Fork me on GitHub
#rdf
<
2023-03-30
>
simongray11:03:11

@eric.d.scott So it turns out that what I need is really a way to write legible qnames inline that either convert to keywords or RDF resource IRIs (since those are what Aristotle likes), but I couldn’t find anything in ont-app vocabulary that did these conversions, so now I have written this:

(defn qname-kw
  "Safely convert a QName `s` into a Clojure keyword."
  [s]
  (let [[prefix identifier :as parts] (str/split s #":")]
    (if (= (count parts) 2)
      (keyword (fmt/encode-kw-ns prefix) (fmt/encode-kw-name identifier))
      (throw (ex-info (str "bad qname: " s) {:input s
                                             :parts parts})))))

simongray11:03:21

I guess it’s either that or a direct conversion to "<>"

quoll20:03:28

Just looking at this discussion now (sorry for my tardiness), but yes, seeing the attempt to do IRIs in keywords looked fraught 🙂 That said, QNames (or CURIEs) are perfect for keywords, as they are quite limited in their syntax, and fall within the domain of keywords