rdf-ext / rdf-parser-csvw

CSV on the Web parser
MIT License
16 stars 4 forks source link

Implement support for prefixes in CSVW #7

Closed ktk closed 6 years ago

ktk commented 6 years ago

Currently the tests are blacklisted.

ktk commented 6 years ago

Did some more tests, not so easy with JSON-LD parser:

There is no specific information for the parser that the URI is prefixed. Among others it generates the following triples:

_:c14n5 <http://www.w3.org/ns/csvw#propertyUrl> "http://vocab.example.org/reference"^^<http://www.w3.org/ns/csvw#uriTemplate> .
_:c14n7 <http://www.w3.org/ns/csvw#propertyUrl> "skos:notation"^^<http://www.w3.org/ns/csvw#uriTemplate> .

Thus I propose we do not implement that for the moment.

ktk commented 6 years ago

@gkellogg I'm a bit surprised that this is not proper JSON-LD in that regard, did we interpret something wrong or is that really like this in the spec? A JSON-LD parser will not properly map the CURIEs to full URIs.

gkellogg commented 6 years ago

I can’t really see what you think isn’t valid JSON-LD. Note that the URI Templates are not URIs, but data types literals; it’s only when applied to a CSV that they become URIs in the output. The triples you show look fine, if you parse the metadata file itself, but that’s not something you would typically do.

If you could share a specific example that does not meet your expectations, and what you think it should be, id be happy to look into it further.

bergos commented 6 years ago

@gkellogg To expand the URI Templates, the prefix map is required. But once the JSON-LD is parsed, that information is lost. That makes prefixes in URI Templates a serialization specific feature.

gkellogg commented 6 years ago

The CSVW Metadata does have the form of a JSON-LD document, but the algorithms parse it as JSON. In many cases, this doesn’t matter, but in this case, access to the prefixes is necessary to get the prefix map.

Some JSON-LD parsers may (temporarily) retain the prefix map, and make it available post parsing (IIRC, the Ruby parser does this), but that’s certainly nothing the rely on. Proper handling of CSVW Metadata requires using the document in its JSON form. Note that CSVW places other restrictions on the Metadata format as well, so even though you can parse the Metadata to RDF, this isn’t too useful in practice.

bergos commented 6 years ago

@gkellogg Is this described somewhere at "csv2rdf - 6. JSON-LD to RDF"? Sorry, but the spec is really hard to read. Also if you say JSON-LD should be handled like JSON, why call in JSON-LD in the first place? That makes the spec even more confusing.

Which other restrictions on the metadata format are there? Are there any plans to upgrade the spec to solve these problems?

gkellogg commented 6 years ago

@bergos The metadata document format is JSON-LD, but that doesn't necessarily imply that it can be turned into RDF and processed that way. The Tabular Metadata Document defines the JSON-LD dialect used.

The format is JSON-LD, and most uses of JSON-LD work at that level, rather than turning into RDF and dealing with the data model level; this is entirely in keeping with the purpose of JSON-LD.

These are not considered problems in the spec, and there are no plans to change.

bergos commented 6 years ago

I will remove the test in the next release. Also we should maintain a list of features which can't be implemented, caused by that issue, in the readme.