RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.15k stars 555 forks source link

formula_aware requirement in notation3 parser too stringent for turtle? #214

Closed maparent closed 12 years ago

maparent commented 12 years ago

Good day.

I am trying to get some turtle data into a sparql endpoint, and if I understand well the parser to use for turtle is the notation3 parser. (Using tip of rdflib and rdflib-sparqlstore)

I stumbled on the fact that the sparql endpoint is not formula_aware. I am still trying to understand the exact requirements of formula-awareness of a store, but it makes sense to me that my sparql endpoint could not be formula-aware. (I am also working on sparql endpoints which are not context-aware, which is another headache.) Now, the n3 parser asserts formula-awareness, which makes sense for n3 but not for turtle. (Again, even context-awareness should not be necessary!)

Am I missing something obvious (you should use another parser...) or is this a real issue? Do you agree that this requirement should be relaxed?

I have a patch ready, which simply disables the assertion at line 2357 and delays the check implicit at line 897 by replacing the newFormula call by a direct Formula constructor; this leaves the newFormula call at 1373 that will check formula_awareness for full n3.

Aside: at line 895, we have a newFormula call with an argument, which should just fail; it is probably never called?

Now, this simple-minded hack is certainly not the best approach; maybe we want a proper turtle parser, and a N3 parser that subclasses it. Maybe we want to build the turtle parser independently (maybe on the ntriples parser?). I am more than willing to do the work, but I'd like some guidance on which approach would be favored by maintainers.

Best, Marc-Antoine Parent

gromgull commented 12 years ago

You are spot on - the requirement is too stringent.

if possible we should subclass the parser and only relax the checks in the subclass. Writing a new turtle parser from scratch is probably more hassle than it's worth.

maparent commented 12 years ago

Ah? Is it not easier to have the relaxed checks in the superclass? Though I agree that cutting the class in two will not be easy. Anyway, if I took a stab at it, could you review? Marc-Antoine

Le 2012-05-24 à 12:56, Gunnar Aastrand Grimnes a écrit :

You are spot on - the requirement is too stringent.

if possible we should subclass the parser and only relax the checks in the subclass. Writing a new turtle parser from scratch is probably more hassle than it's worth.


Reply to this email directly or view it on GitHub: https://github.com/RDFLib/rdflib/issues/214#issuecomment-5911646