Csv virtual graph multiple triples for the same subject

My CSV looks like that:
sender,recipient,subject
u1,u10,"first-subject"
u2,u12,"second-subject"
u1,u12,"third-subject"

I am struggling to create a mapping ttl that would capture both row 2 and row 4. Currently I have:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sm: <tag:stardog:api:mapping:> .

:User-{recipient} a :Recipient ;
    rdfs:label"{recipient}" .

:User-{sender} a :Sender ;
    rdfs:label"{subject} sent by {sender}" ;
    :subject "{subject}" ;
    :recipient :User-{recipient} .

Attached picture shows created tripples and obviously a missing one: "fist-subject sent by u1"

Hi Radu,

That looks odd indeed. If you duplicate the first line with data, are the proper triples generated?

Jess

Yes - when duplicating the fist (i.e. second row)
sender,recipient,subject
u1,u10,"first-subject"
u1,u10,"first-subject"
u2,u12,"second-subject"
u1,u12,"third-subject"

No triples are added:
Successfully imported 0 triples into Test3

What is the result of using data export to export this database in Turtle format?

Here it is:

@prefix stardog: <tag:stardog:api:> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix dcterms: <http://purl.org/dc/terms/> .

:User-u1 a :Sender ;
   rdfs:label "first-subject sent by u1" , "third-subject sent by u1" ;
   :subject "third-subject" , "first-subject" ;
   :recipient :User-u12 , :User-u10 .
:User-u12 a :Recipient ;
   rdfs:label "u12" .
:User-u2 a :Sender ;
   rdfs:label "second-subject sent by u2" ;
   :subject "second-subject" ;
   :recipient :User-u12 .
:User-u10 a :Recipient ;
   rdfs:label "u10" .

Looks like your graphical output is not showing both of these labels.

Indeed

Thank you - now i now how to export to ttl :wink:

Is it possible to run a sparql update and convert the following:

rdfs:label "first-subject sent by u1" , "third-subject sent by u1" ;

to
rdfs:label "first-subject sent by u1 , third-subject sent by u1" ;

?

Try this:

delete { ?node rdfs:label ?label }
insert { ?node rdfs:label ?newLabel }
where {
  { select ?node (group_concat(?label) as ?newLabel) {
    ?node rdfs:label ?label
  } group by ?node }
  ?node rdfs:label ?label
}

Jess,

Ok in the ttl export I see it by why is this query select * where{?s ?p ?o} not returning this label at all?

"third-subject sent by u1"

Thanks,
Radu

Did you run the update statement? What labels are being returned?

I ran it and the export looks like that now:
:User-u1 a :Sender ;
rdfs:label "first-subject sent by u1" ;
:subject "first-subject" ;
:recipient :User-u12 , :User-u10 .
:User-u12 a :Recipient ;
rdfs:label "u12" .
:User-u2 a :Sender ;
rdfs:label "second-subject sent by u2" ;
:subject "second-subject" ;
:recipient :User-u12 .
:User-u10 a :Recipient ;
rdfs:label "u10" .

Never mind - it worked:

:User-u1 a :Sender ;
   rdfs:label "first-subject sent by u1 third-subject sent by u1" ;
   :subject "third-subject" , "first-subject" ;
   :recipient :User-u12 , :User-u10 .
:User-u12 a :Recipient ;
   rdfs:label "u12" .
:User-u2 a :Sender ;
   rdfs:label "second-subject sent by u2" ;
   :subject "second-subject" ;
   :recipient :User-u12 .
:User-u10 a :Recipient ;
   rdfs:label "u10" .

Visualization looks accurate now:

Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.