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.17k stars 556 forks source link

Failed to parse Turtle URL ending with a dot #933

Closed sharpaper closed 2 years ago

sharpaper commented 5 years ago

This is valid Turtle syntax

PREFIX : <http://example.org/>
:0A\.D\. :key :value .

but RDFLib is failing to parse it. It does not parse the second dot in :0A\.D\.

How to reproduce:

#!/usr/bin/env python3

from rdflib import Graph

data = """
PREFIX : <http://example.org/>
:0A\.D\. :key :value .
"""

node = Graph()
node.parse(data=data, format="turtle")

And the error message:

rdflib.plugins.parsers.notation3.BadSyntax: at line 4 of <>:
Bad syntax (objectList expected) at ^ in:
"b'\nPREFIX : <http://example.org/>\n\n:0A\\.D\\. :key :value'^b' .\n'"

Is this a bug or am I doing something wrong?

Tanish-Gupta commented 4 years ago

Is this still an issue?

luckyagarwal commented 4 years ago

@sharpaper So this is not a bug. if you do the following modification in your input stream to the node.parse() it fixes the issue.

from rdflib import Graph

data = """
PREFIX : <http://example.org/>
:0A\.D\. :key\. :value .
"""
sanyam19106 commented 4 years ago

from rdflib import Graph data=""" PREFIX : <http://example.org/> :0A\.D\. :key . :value . """ g = ConjunctiveGraph() g.parse(data=data, format="turtle")

In the data file missing the "." after the key because :0A.D\ . is the a triple which has only subject not a predicate and object so that every triples ends with the "." (dot) ,similarly :key is also a triple which has no predicate and object so we need to put "." after the :key .

ghost commented 2 years ago

Not actually an issue, closing.