rdf 2025-01-27

In that last thread I described a new version of Raphael that prints properly at a Cider repl, though it doesn't change anything else from 0.3.10. But I'm able to parse that document without an issue. Can you create a minimal document that shows the error?

@quoll thanks for looking at this, and apologies for the slow response, I was traveling this past week. So, I continue to thrash around trying to isolate what is happening. I filed https://github.com/quoll/raphael/issues/8 with an updated test file that reproduces the issue for me.

I responded to this just now. I get the same error that you're reporting because the code block for the TTL you've included has a   in the position just before the "qbert" string. I'm thinking that maybe you have another character that looks like a space at the terminal, and the github web page converted it into a non-blocking space character instead.

Are you able to check what the character code(s) for that position is, please? I think I'm parsing for all acceptable whitespace, but maybe I've missed a unicode character I'm supposed to handle

I just checked the spec, and it says:

[161s]	WS	::=	#x20 | #x9 | #xD | #xA /* #x20=space #x9=character tabulation #xD=carriage return #xA=new line */
I'm using the following for whitespace:
(def whitespace? #{\space \tab \return \newline})

These come out to the correct numbers:

=> (map #(Long/toHexString (int %)) [\space \tab \return \newline])
("20" "9" "d" "a")

Oh cool! I just remembered… I can do this now:

=> (map (comp Long/toHexString int) [\space \tab \return \newline])
("20" "9" "d" "a")

1

OMG, I had thought of this and had tried to show whitespace characters in VS Code. What is interesting is that this file was generated by Donatello but maybe when I viewed the Turtle file in a text editor (like TexEdit on the Mac) something got added. You've identified the core issue so let me look on my side about what may be the ultimate cause.

So this is kind of insidious because I am pressing Option all the time using Calva to execute various key chords, and on Mac Option-Space inserts an nbsp. There is this Marketplace item to help with just this issue: https://marketplace.visualstudio.com/items?itemName=viktorzetterstrom.non-breaking-space-highlighter&ssr=false#overview

OK, I think the problem is solved here. I am taking data from CSV files and creating RDF triples that I am using Donatello to write up. In that source data, there are a handful of places where nbsp chars are in column names and the column names become my predicates.

Interestingly, clojure.string/trim does not trim nbsp. I have closed the issue on GitHub. Thanks again for your help and making RDF work in Clojure easy!

❤️ 1

No need to close! I want to update the error message. After all, the error you've been seeing did not help you

👍 just re-opened.

I copy/pasted the doc you included into data.ttl. Then I loaded it using a Cider repl:

(def f (slurp "data.ttl"))
#'quoll.raphael.core/f
quoll.raphael.core> (def r (parse f))
#'quoll.raphael.core/r

Then I printed r:

r
{:namespaces
 {"rdf" "",
  "rdfs" "",
  "ent" "tag:",
  "attr" "tag:,
 :triples
 ([{:iri
    "tag:",
    :prefix "ent",
    :local "1efd782a-47b7-6790-8487-440cb3ab6e31"}
   {:iri "tag:",
    :prefix "attr",
    :local "paths"}
   "0101, 1010"]
  [{:iri
    "tag:",
    :prefix "ent",
    :local "1efd782a-47b7-6790-8487-440cb3ab6e31"}
   {:iri "tag:",
    :prefix "attr",
    :local "sop_ref_id"}
   12345]
  [{:iri
    "tag:",
    :prefix "ent",
    :local "1efd782a-47b7-6790-8487-440cb3ab6e31"}
   {:iri "tag:",
    :prefix "attr",
    :local "build"}
   ""]
  [{:iri
    "tag:",
    :prefix "ent",
    :local "1efd782a-47b7-6790-8487-440cb3ab6e31"}
   {:iri "tag:",
    :prefix "attr",
    :local "vendor"}
   "ACME"]
  [{:iri
    "tag:",
    :prefix "ent",
    :local "1efd782a-47b7-6790-8487-440cb3ab6e31"}
   {:iri "tag:",
    :prefix "attr",
    :local "cat"}
   1]
  [{:iri
    "tag:",
    :prefix "ent",
    :local "1efd782a-47b7-6790-8487-440cb3ab6e31"}
   {:iri "tag:",
    :prefix "attr",
    :local "project_code"}
   8675309]
  [{:iri
    "tag:",
    :prefix "ent",
    :local "1efd782a-47b7-6790-8487-440cb3ab6e31"}
   {:iri "tag:",
    :prefix "attr",
    :local "number"}
   "C2187"]
  [{:iri
    "tag:",
    :prefix "ent",
    :local "1efd782a-47b7-6790-8487-440cb3ab6e31"}
   {:iri "tag:",
    :prefix "attr",
    :local "pattern_type"}
   "p1x1"]
  [{:iri
    "tag:",
    :prefix "ent",
    :local "1efd782a-47b7-6790-8487-440cb3ab6e31"}
   {:iri "tag:",
    :prefix "attr",
    :local "elastic"}
   "no"])}

The triples are a bit messy since the IRIs take up 3 lines each, but everything appears to be correct.