I have a jsonld representation of triples :
{"@id": "some-id",
"@type": "Row",
"attendance": 74439,
"average_cards_per_match_pre_match": 0,
"average_corners_per_match_pre_match": 0,
"average_goals_per_match_pre_match": 0,
"my_field" : [-0.0368623323738575, 0.06313438713550568,
-0.05376605689525604, -0.0368623323738575, 0.06313438713550568, -0.05376605689525604]
}
When parsing using rdflib :
g = Graph()
g.parse(
data=json.dumps(jsonld_response),
format="json-ld",
context={
"@vocab": "/",
"@language": "en",
"rdfs": ";,
},
)
g.serialize(format="xml")
The duplicate values of the my_field are removed and only three triples are created in the resultant rdfxml.
<my_field rdf:datatype=";>-0.0368623323738575</my_field>
<my_field rdf:datatype=";>0.06313438713550568</my_field>
<my_field rdf:datatype=";>-0.05376605689525604</my_field>
Is there a way to make sure duplicate values are not truncated?
I have a jsonld representation of triples :
{"@id": "some-id",
"@type": "Row",
"attendance": 74439,
"average_cards_per_match_pre_match": 0,
"average_corners_per_match_pre_match": 0,
"average_goals_per_match_pre_match": 0,
"my_field" : [-0.0368623323738575, 0.06313438713550568,
-0.05376605689525604, -0.0368623323738575, 0.06313438713550568, -0.05376605689525604]
}
When parsing using rdflib :
g = Graph()
g.parse(
data=json.dumps(jsonld_response),
format="json-ld",
context={
"@vocab": "http://example/test/",
"@language": "en",
"rdfs": "http://www.w3./2000/01/rdf-schema#",
},
)
g.serialize(format="xml")
The duplicate values of the my_field are removed and only three triples are created in the resultant rdfxml.
<my_field rdf:datatype="http://www.w3./2001/XMLSchema#double">-0.0368623323738575</my_field>
<my_field rdf:datatype="http://www.w3./2001/XMLSchema#double">0.06313438713550568</my_field>
<my_field rdf:datatype="http://www.w3./2001/XMLSchema#double">-0.05376605689525604</my_field>
Is there a way to make sure duplicate values are not truncated?
Share Improve this question asked Mar 19 at 13:02 RishabhgRishabhg 1189 bronze badges1 Answer
Reset to default 2In RDF a statement is either stated or not stated and there is no order of statements. It does not make a difference, whether you state a statement once, twice, … and in which order you state them. If repetition or order of values matters, you can e.g. use an rdf:List. To state an rdf:List in JSON-LD, you can extend the context in your case by:
"my_field": {
"@container": "@list"
}
This should cause the parser to consider the array values as members of an rdf:List.