You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im trying to serialize some RDF graph generated from CSV file by using of package: https://pypi.org/project/csvwlib/
Passing None as format to CSVWConverter.to_rdf() method returns normal instance of rdflib.graph.Graph class.
CSV file content is:
John,Doe,120 jefferson st.,Riverside, NJ, 08075
Jack,McGinnis,220 hobo Av.,Phila, PA,09119
"John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075
Stephen,Tyler,"7452 Terrace ""At the Plaza"" road",SomeTown,SD, 91234
,Blankman,,SomeTown, SD, 00298
"Joan ""the bone"", Anne",Jet,"9th, at Terrace plc",Desert City,CO,00123
Precisely, what I'm doing:
from csvwlib import CSVWConverter
graph = CSVWConverter.to_rdf("http://localhost:8000/media/resources/20210630/tmpsn0l02m9.utf8_encoded.csv", format=None))
for s, p, o in graph:
print(s, p, o)
data = graph.serialize(format='json-ld', auto_compact=True).decode()
print(jsonld_data)
Why jsonld_data contains all default namespaces as @context even if only one of them (csvw) occurs inside @graph section?
Using any of "default" formats as n3 or ttl, returns completely different namespaces:
data = graph.serialize(format='n3').decode()
print(data)
A real solution here would be to introduce a checker into the rdflib-jsonld code to ensure only used namespaces are placed into Context. Another solution would be to do a similar thing in csvwlib i.d. only bind used prefixes to the graph.
While I think either or both could be done, I would have to check if it's expected JSON-LD behaviour: perhaps there is no requirement that context be limited in this way - to used context elements only - and there may even be reasons why it's not desired, but I suspect that it is not desired behaviour.
Sorry I don't know already, I'm pretty new to JSON-LD as I'm actually one of the rdflib maintainers and have sort of inherited rdflib-jsonld.
I'm not going to be able to fix this any time soon - I'm preoccupied with merging rdflib-jsonld into rdflib main library and adding JSON-LD 1.1 support - so I'd love any external contributions for this.
Hello there!
Im trying to serialize some RDF graph generated from CSV file by using of package: https://pypi.org/project/csvwlib/
Passing None as format to CSVWConverter.to_rdf() method returns normal instance of rdflib.graph.Graph class.
CSV file content is:
Precisely, what I'm doing:
Printed data is:
My question is:
Why jsonld_data contains all default namespaces as @context even if only one of them (csvw) occurs inside @graph section?
Using any of "default" formats as n3 or ttl, returns completely different namespaces:
Result:
Versions of packages:
csvwlib==0.3.2
rdflib==5.0.0
rdflib-jsonld==0.5.0
Please let me know if described behavior is a potential error or not. Is there any way to get the same namespaces in context of json-ld as for n3?
The text was updated successfully, but these errors were encountered: