RDFLib/rdflib — Issue #152: Notation3 parser dot issue
Author: gjhiggins
Created: 2012-02-20 08:33:56+00:00
State: open

fertap...@gmail.com, 2011-03-24T17:17:56.000Z

Hi,
I'm using FuXi as inference engine, and it receives the rules expressed in N3 format. Everything goes ok until I need to put a Freebase predicate such as http://rdf.freebase.com/ns/object.type.name.
The N3 parser doesn't distinguish between the "AND operator" dot and the dots of the predicate's URI.

This is an example of a dot used as AND operator:
{?P @has rdfs:range ?C. ?S ?P ?O} => {?O a ?C}.

and this is my N3 rule:
{?S fb:object.type.name ?O} => {?S a fb:namedPerson}.

and I get the error:
File "/Library/Python/2.6/site-packages/rdflib/plugins/parsers/notation3.py", line 1198, in path
"EOF found in middle of path syntax")
rdflib.plugins.parsers.notation3.BadSyntax: at line 44 of <>:
Bad syntax (EOF found in middle of path syntax) at ^ in:
"@prefix log: .
@prefix str: .
@prefix owl: .
@prefix xsd: .
@prefix rdfs: .
@prefix rdf: .
@prefix e: .
@prefix fb: .
@prefix cc: .
@prefix : .

### Resource Description Framework RDF(S)

rdf:Alt rdfs:subClassOf rdfs:Container.
rdf:Bag rdfs:subClassOf rdfs:Container.
rdfs:ContainerMembershipProperty rdfs:subClassOf rdf:Property.
rdfs:Datatype rdfs:subClassOf rdfs:Class.
rdf:Seq rdfs:subClassOf rdfs:Container.
rdf:XMLLiteral rdfs:subClassOf rdfs:Literal; a rdfs:Datatype.

rdfs:comment rdfs:domain rdfs:Resource; rdfs:range rdfs:Literal.
rdfs:domain rdfs:domain rdf:Property; rdfs:range rdfs:Class.
rdf:first rdfs:domain rdf:List; rdfs:range rdfs:Resource; a owl:FunctionalProperty.
rdfs:isDefinedBy rdfs:domain rdfs:Resource; rdfs:range rdfs:Resource; rdfs:subPropertyOf rdfs:seeAlso.
rdfs:label rdfs:domain rdfs:Resource; rdfs:range rdfs:Literal.
rdfs:member rdfs:domain rdfs:Container; rdfs:range rdfs:Resource.
rdf:object rdfs:domain rdf:Statement; rdfs:range rdfs:Resource.
rdf:predicate rdfs:domain rdf:Statement; rdfs:range rdf:Property.
rdfs:range rdfs:domain rdf:Property; rdfs:range rdfs:Class.
rdf:rest rdfs:domain rdf:List; rdfs:range rdf:List; a owl:FunctionalProperty.
rdfs:seeAlso rdfs:domain rdfs:Resource; rdfs:range rdfs:Resource.
rdfs:subClassOf rdfs:domain rdfs:Class; rdfs:range rdfs:Class.
rdfs:subPropertyOf rdfs:domain rdf:Property; rdfs:range rdf:Property.
rdf:subject rdfs:domain rdf:Statement; rdfs:range rdfs:Resource.
rdf:type rdfs:domain rdfs:Resource; rdfs:range rdfs:Class.
rdf:value rdfs:domain rdfs:Resource; rdfs:range rdfs:Resource.

rdf:nil a rdf:List.

### inference rules for RDF(S)

{?S fb:object.type.name ?O} => {?S a fb:conNombre}^..."

Thanks in advance

Comment 1 by gromgull
The rdflib behaviour appears to be right:

"{?S fb:object.type.name ?O} => {?S a fb:namedPerson}."

is not valid n3, qnames cannot contain "." - look here:

http://www.w3.org/2000/10/swap/grammar/n3-report.html#qname

There is no "." in the part of the regex after ":"

The solution would be to redefine the prefix and qname, i.e. instead of:

@prefix fb :
fb:object.type.name

you must have:

@prefix fb :
fb:name

Comment 2 by fertap...@gmail.com
Hi gromgull,
it worked. I tried to redefine the namespace earlier, but I had a typo error: instead of object.type.name is type.object.name, and I directly thought that it was a N3 parser error...what a stupid mistake.
Either way, thanks for your quick response.
Regards

Comment 3 by gromgull