Closed GoogleCodeExporter closed 8 years ago
Can you attach the output of `svn diff` to this ticket please? It will make
applying the patch a lot easier.
Original comment by ed.summers
on 27 Nov 2010 at 2:30
As an attachment... It should apply with 'patch -p1 < qname_prefix.diff'
Original comment by wwai...@gmail.com
on 27 Nov 2010 at 11:00
Attachments:
Original comment by ed.summers
on 28 Nov 2010 at 10:48
Original comment by ed.summers
on 28 Nov 2010 at 10:48
I guess we can chalk this up to a difference between Turtle and N3. Turtle is a
subset of N3. So what is valid N3 isn't necessarily valid Turtle. In this case
N3 allows prefixes to start with a underscore, and Turtle does not. And redland
understands Turtle, whereas rdflib understands N3 :-)
That being said I think it makes sense to encourage a bit more interoperability
between redland and rdflib by making the change you suggest:
<pre>
>>> g = rdflib.Graph()
>>> g.add((rdflib.URIRef('http://example.com/foo'),
rdflib.URIRef('http://example.com/bar'), rdflib.Literal(1)))
>>> print g.serialize(format='n3')
@prefix _3: <http://example.com/> .
<http://example.com/foo> _3:bar 1
</pre>
will become:
<pre>
>>> g = rdflib.Graph()
>>> g.add((rdflib.URIRef('http://example.com/foo'),
rdflib.URIRef('http://example.com/bar'), rdflib.Literal(1)))
>>> g.serialize(format='n3')
'@prefix ns1: <http://example.com/> .\n@prefix ns2:
<http://www.w3.org/2001/XMLSchema#> .\n\nns1:foo ns1:bar 1 .\n\n'
>>> print g.serialize(format='n3')
@prefix ns1: <http://example.com/> .
@prefix ns2: <http://www.w3.org/2001/XMLSchema#> .
ns1:foo ns1:bar 1 .
</pre>
It's interesting that the subject and object URIs becomes prefixed after this
change. I wonder if that could potentially end up blowing up the number of
prefixes used when serializing as N3?
Original comment by ed.summers
on 28 Nov 2010 at 11:48
I'm not sure this "blowing up" of prefixes demonstrated in test.py (attached)
is good for large graphs:
before patch:
% ./test.py
<http://example.com/person1#i> a <http://xmlns.com/foaf/0.1/Person> .
<http://example.com/person2#i> a <http://xmlns.com/foaf/0.1/Person> .
<http://example.com/person3#i> a <http://xmlns.com/foaf/0.1/Person> .
<http://example.com/person4#i> a <http://xmlns.com/foaf/0.1/Person> .
<http://example.com/person5#i> a <http://xmlns.com/foaf/0.1/Person> .
<http://example.com/person6#i> a <http://xmlns.com/foaf/0.1/Person> .
<http://example.com/person7#i> a <http://xmlns.com/foaf/0.1/Person> .
<http://example.com/person8#i> a <http://xmlns.com/foaf/0.1/Person> .
<http://example.com/person9#i> a <http://xmlns.com/foaf/0.1/Person> .
after patch:
% ./test.py
@prefix ns1: <http://example.com/person5#> .
@prefix ns10: <http://example.com/person9#> .
@prefix ns2: <http://xmlns.com/foaf/0.1/> .
@prefix ns3: <http://example.com/person4#> .
@prefix ns4: <http://example.com/person3#> .
@prefix ns5: <http://example.com/person6#> .
@prefix ns6: <http://example.com/person1#> .
@prefix ns7: <http://example.com/person7#> .
@prefix ns8: <http://example.com/person2#> .
@prefix ns9: <http://example.com/person8#> .
ns6:i a ns2:Person .
ns8:i a ns2:Person .
ns4:i a ns2:Person .
ns3:i a ns2:Person .
ns1:i a ns2:Person .
ns5:i a ns2:Person .
ns7:i a ns2:Person .
ns9:i a ns2:Person .
ns10:i a ns2:Person .
Original comment by ed.summers
on 28 Nov 2010 at 12:19
Attachments:
attached patch modifies the turtle serialiser to prevent prefix explosion...
Original comment by wwai...@gmail.com
on 28 Nov 2010 at 1:26
Attachments:
[deleted comment]
I'm just realizing now that the Turtle serializer emits the prefix with a
leading underscore...so this really is a defect.
Original comment by ed.summers
on 28 Nov 2010 at 2:37
This issue was closed by revision r1899.
Original comment by ed.summers
on 28 Nov 2010 at 3:47
This issue was closed by revision dcea99e96edc.
Original comment by ed.summers
on 30 Mar 2011 at 9:07
Original issue reported on code.google.com by
wwai...@gmail.com
on 26 Nov 2010 at 10:53