Letractively / rdflib

Automatically exported from code.google.com/p/rdflib
Other
0 stars 0 forks source link

Notation3 parser dot issue #164

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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: <http://www.w3.org/2000/10/swap/log#>.
@prefix str: <http://www.w3.org/2000/10/swap/string#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>.
@prefix fb: <http://rdf.freebase.com/ns/>.
@prefix cc: <http://creativecommons.org/ns#>.
@prefix : <http://eulersharp.sourceforge.net/2003/03swap/rdfs-rules#>.

### 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

Original issue reported on code.google.com by fertap...@gmail.com on 24 Mar 2011 at 5:17

GoogleCodeExporter commented 8 years ago
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 : <http://rdf.freebase.com/ns/>
fb:object.type.name

you must have:

@prefix fb : <http://rdf.freebase.com/ns/object.type.>
fb:name

Original comment by gromgull on 25 Mar 2011 at 7:40

GoogleCodeExporter commented 8 years ago
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

Original comment by fertap...@gmail.com on 25 Mar 2011 at 8:23

GoogleCodeExporter commented 8 years ago

Original comment by gromgull on 27 Aug 2011 at 6:48